How can I fix my garage door lock?
First off I seriously doubt that the lock cylinder pulling out like that is anything even close to its normal operation. In fact it is an indication that the lock itself is seriously broken. 

Normal behavior for a cheap lock like that is to have two positions (locked and unlocked) where the key can pull out of its slot in either position. However the lock cylinder stays in place. The two rotational positions for the lock will generally be either a quarter turn or half turn from each other.

Since you have mentioned that the garage door has an electric opener please be aware that 90% or more of people never use their garage doorlocks due to the inconvenience of having to get out of the vehicle in order to open the garage door. This disuse of the lock over years leads to the thing becoming corroded and sometimes fully freezing up. It does not help that these cheap locks are made of cheap pot metal or poorly plated iron that invites the corrosion. 

If you need servicable locks then I would suggest that you will likely want to replace these with some better quality retrofit latch/lock assemblies.

To get working garage door remotes you could do what I did. First I threw away all the old garage door remotes that had quit working. Then I went to eBay and purchased a set of remote controlled relays similar to that shown below. The relay board gets mounted inside the garage on the wall near the manual open/close button. The N.O. and COM terminals of the relay get connected in parallel to the manual switch connections. Then a 12VDC wall power adapter is wired into the relay unit to provide power. The adapter plugs into a nearby AC mains outlet. (I found a suitable 12VDC power adapter on the shelf at my local Goodwill outlet for ~2$US). If you have two garage doors the relay unit shown below can support both door openers separately from one remote fob.



A couple of additional things to be aware of: 


If you want more than one fob either purchase two relay kits or look around for a seller that bundles two fobs with the kit.
The fob and relay unit need to be paired with the same code. As shipped the seller normally has arranged for the proper pairing but typically sets all units to the same code. These units support many hundreds of codes and you may elect to change the pairing code before installing the unit. The codes are set inside the fob and on the relay board via simple solder blob connections.