Jump the gun
The gun referred to is the starter’s pistol that was first used to start races during the late 19th century and along with trying to beat the gun or beat the pistol were once commonly heard phrases. In the figurative sense of starting something too early or getting ahead of oneself, it is first attested only in the 1940s.