First thing I would check are the "detents" - which are located in the shifter tower. You can remove just the tower and bring it to your workbench for examination.
On the two sides of the shifter tower you'll find a threaded plug.
What can happen is gunk can get in the springs/pills/under the threaded plugs and prevent the pills from engaging the depressions in the shifter rails - i.e. won't hold in gear.
Note that "2" (intermediate) gear is push lever away from driver and forward. This means the shifter rail that may need attention is "closer" to the driver.
The actual "detent" is shared between the left and right rails and located between the rails. Undoing the plugs just gives "access" to the detent spring and plungers once the rails are removed. So you'll have to disassemble the rails from their forks, and remove them through the front holes on the shifter tower.
This is not a hard job but smaller hands help, as does having a pin punch that can fit the rivet and punch out the long rivets holding the forks to the rails. (going back together you can use a large center punch with a 60 degree cone to expand the rivet for retention.)
With the rails removed, you can undo the threaded plugs and "pour" the pill detents and springs out into your hand - and clean the entire assembly internally for re-assembly.

If on re-assembly you find operation of the shifter and detents satisfactory, then the issue is more "internal" to the transmission. I have seen 2nd sliding gears to be "worn" on the leading edges and could cause the defect that you're seeing. You may see this with the transmission top off. But check the shifter detents while things are apart. Cleaned in the detent area, there may be enough to "hold" it in gear. This you can do without pulling the engine/transmission.
Joe K