One thing to check is the selector shaft plunger. It's basically a spring with a ball fitting at the end that engages the transfer gear selector's rod when in gear. There is an indent in that selector rod that the plunger ball sinks into to help the rod stay in gear. The spring and plunger are held in place by a brass plug/nut that you can access from under the middle seat box access cover.
See the image below (number 6). Make sure the spring is in good condition and the plunger is engaging properly.
1968 Series IIa
1997 Defender SW (Original Owner - Sold)