How can I fix my window frame so that the window doesn't drop down?
These are called spring balances, and have enough tension in the spring to hold the window open (sorry about your hand).  It's kind of hard to tell from the pictures you posted what type they are (other than older ones), but you should be able to find some instructions for a model similar to yours now that you know what to search for. 

In general, you'll want to attach them at the bottoms first and then lift up the sash to allow re-attaching the tops.  This is a lot easier with 3 hands, so you might want to have someone hold the sash up or prop it if you can find something the right height.