Welcome to the Marshall world
I bought my M22 a year ago last spring and have never regretted it. I have a 3GMD in mine, but essentially the same engine transmission combo and pretty bullet proof. There is a transmission oil fill plug with dipstick under it on the top of the transmission that you should check for good measure. These don't hold much oil (less than 1 quart, if I remember right). Assuming oil level is adequate, I would focus on the engine control lever by the wheel, particularly the pull out knob that disengages the gears for fast idle, etc. If that is not fully engaging, it could do just what you are seeing. Next time it happens, before you do other things like jump overboard, try pulling the knob out and reseating it back in fully, with shift fully in neutral not in gear when you do that. When I got mine, there was quite a bit of play in that whole assembly, but very little actual wear. I was able to tighten up mine very easily after pulling the cover bezel, but most of my play was in the mounting to the bulkhead, so not exactly your position. the engine/transmission manual is on-line at Yanmar, and the folks at Torreson are a wealth of Yanmar information. If you haven't connected with Geoff Marshall at Marshall Marine, you should also do that. I have found them to be a great resource for their older boats, and very competitive for supplying all sorts of stuff like a really useful cam cleat
system for the mainsheet, and a set of pre-cut teak parts to encase the centerboard trunk section that is out in the cockpit. They even have small stuff like the right lenses for the bronze running lights
, replacement mast boots, hops, etc.... It is a plus that my 25 year old boat is still in production in almost exactly the same configuration as mine, as well as having the builder's yard not over an hour from home (fun place to visit).