The gear switcher (cycling terminology: Shifter) should be attached via a band with a simple bolt through it. The shifter will attach to the handlebar (right side for rear shifter/ left side for front shifter).
If you have shifters that are shaped like a barrel as in the picture, then you have to remove the grip on the side you will install the shifter. slide the shifter onto the bar and tighten the set screw in the housing (should be just back of where the cable comes out). Reinstall the grip and there you go.
This is a simple proceedure, however if things are not tightened properly you can get into an accident, for this reason I would recommend taking the bike to a bike shop and having them reinstall the shifter and make sure that everything is safe and functioning properly.
Final Note: If your shifter was on the bike and functioning properly and fell off, then you need to go into a bike shop. The shifter has something broken and either needs to be replaced or fixed. Shifters do not just fall off.