I have cycled through a LOT of M's over the years - mostly bought used too.
When I look at them, initially I look at the overall condition, scratches, dents, "burred" screw heads - as this tend to indicate ham-fisted approches to repairs.
I then pop the pack open, check the condition of the shutter curtains - advance and "shoot" and check the the curtains slide properly across. If the "bar" on the 2nd curtain shows at the left of the film-gate - it usually means that it needs tuning. Also look for the condition of the actual curtains - no discoloration, no wrinkles or cracks ( that indicates a shutter curtain replacement). I also cycle through all the speeds - holding the camera up against a light (no lens on it). This way you can judge if the speeds are reasonably correct and that there is no "capping". Even at 1/500 or 1/1000 you should see a brief view of the light.
Once this established, I check the film pressure plate - is it worn (mirror like marks on it) or, in worst case scenario - does it have what looks like "groove" going across it. The sprocket gear will show brassing quite quickly so it is not a firm indication of the amount of film that has gone through.
If it is an early M (M1/M2/M3) - pull out the film spool and check its condition. Lots of brassing on this will indicate a lot of films! Also check that the spool fits snugly over the take-up shaft. If it feels "loose" you can end up with overlapping images as it slips.
On M4 and later models - check the condition of the film take up "tulip" - is it brassy or very loose. They do have a slight sideways movement to it - but it should feel solid and anchored to the take-up drive.
Check the advance action, is it smooth and positive? Any "rough" spots could mean worn or cracked gears in the advance mechanism. The lever should feel 'solid" but not tight. There is a slight "slop" in it - both in pulling it out for advance and up/down. If not, it can be overtightened to hide worn mechanism.
Finders are easy to check. Are the framlines bright and contrasty. Dont worry about smallish black specks on them. This is flakes from black out paint that migrates there. They should be solid - no irregular "breaks" in the lines as that indicates oxidization of the reflective mirriors and can be a problem in the future.
Is the rangefinder patch clear and contrasty. Does it move smoothly across the focussing range (just push lightly on the "wheel" at the top of the lens mount opening - dont force it.
Look through the finder window from the front. Are there "blotches" or lines showing up? There is bound to be some with an older cameras - but if they dominate the finder view - beware. Some dust is OK - particularly on an older M. With time it will accumulate. However, if the camera is a 40-50 year old M - how much more can you expect over the next 40 years!
If you can, put a lens on the camera, preferably a 50 or a 90 and check that the frames showing up are clear. The "switch" for the M's have the 35 as a default setting and when there is no lens on the camera - this is the frame that should show up. The "pre view" lever should move smoothly and kick in the correct frames with out "double image" (50 frame faintly visible when the 35 lens is on.
If there is a selftimer - check its action. On older M's they can get sluggish with time and lack of use. Usually just needs exercise though.
Occasionally you encounter M's with the self timer lever "flopping" around and no action. Usually indicates that someone has taken it off and mucked up re-installing it. Not a big deal anyway. Happens frequently when owners "recover" the body.
If the camera meets these requirement and the price is OK - just buy it and load up and shoot! That's what it is for and that's why you want it.
If it is a mint looking camera - be gentle when you try functions as it is most likely quite dry and lubricants have migrated away from bearings and shafts.
Once you have the camera in hand, shoot some fllm and check speeds throughout the range - check spacing between frames etc. After a couple of 100 rolls - give the camera a basic CLA and you should be set for the next 20-30 years.
These tips are generally for older, used M's - but I apply the same principles to a new camera. M's are mechanical devices and as such hate sitting idle. Who knows how long a camera has sat in a warehouse or in a dealers stock? And - Yes, I have had new M's fail these tests - not often, but it can happen.