If you jump the gun, you do something before the expected or correct time. Buying a wedding present for a friend before she's even proposed to her partner would be jumping the gun.
This expression comes from racing, where a gun is traditionally fired as a signal to start running. In this context, to jump the gun means to start running before the go signal has been given, which is a major no-no for a competitor. Nowadays, the phrase has become more general, and jumping the gun means doing something too early — often in a way that makes your life slightly worse.