This is a good question.
This grammar structure is common, but I understand why it could be confusing.
Both of these sentences tell you 2 things.
a) He injured his knee. He was playing hockey.
b) I was up all night. I was updating my blog.
The 2nd half of each sentence gives you information about the first half, like an explanation.
a) He injured his knee.
(How did he injure his knee?)
Playing hockey.
b) I was up all night.
(Why were you up all night?)
Updating my blog.
We combine these two things as a way to be more concise and to tell a story that makes sense.
A real English professor can probably give you a better explanation, but maybe this answer will help you.
Good luck!