An M5 bolt will thread into a 10-32 nut, and then bind, resulting in an insecure fastening and probably ruined fasteners. A 10-32 bolt will thread into an M5 nut, but won't hold. A 10-24 bolt's threads are obviously too coarse, especially if you have an M5 to compare, but it's still nearly the right size. If you use a bit of force, a 10-24 bolt will thread into an M5 nut a few turns, and then seize. If you keep forcing, you'll probably strip the nut. Most bike bosses are M5, so forcing a 10-24 bolt into a bike boss is a quick way to banjax a bike frame. Don't ask me how I know this. (The simple solutions are to either drill and tap the boss out to M6 or use a nut on the back side forever.)
A metric/SAE screw gauge costs $4. That's a one-beer tool. A metric thread gauge is $7, a beer-and-a-half tool. So I have these, and if I'm at all doubtful of the path by which a fastener came to be headed towards my bike, out come the gauges. It's much faster than half breaking a boss and then having to half-fix it.
And I keep my bike fasteners well separate from anything that might be SAE. Harder to do at home than it would be in a bike shop, but it's not that big a deal to buy a $10 plastic bin tray to hold just my bike fasteners, nothing else allowed. SAEs who? SAEs me!
*Yeah, yeah, I know there are no "SAE" fasteners since, 1949, when UTS superseded SAE. Go ahead and try to buy a "UTS" fastener in a hardware store. Thought so.