Very vague question. Different units use different mechanical methods. Ford 3.03 top loaders use "shift keys". Most have some sort of spring detent on the shift rails.
and the part that keeps it there, isn't always the part that is not working right, and making it jump out of gear.
A fork slides a coupler ring over the syncros to engage the gear to the cluster and output shaft. The stick bone’s connected to the fork bone, the fork bone’s connected to the synchro bone…..
The OP does not say what type of transmission or how it is being shifted. Column or floor shift, internal shift? T-5 style? Generally, either worn out parts or needs adjustment.