In a perfect world, every rider on every ride would carry a spare for every one of their bikes' likely-to-be-lost-or-broken bolts. But then again, if we lived in a perfect world bolts would never get lost or broken. So if you do find yourself needing a fast fastener, there may already be one on your bike.
M5-sized bolts are commonly used in the clamps for saddles, seatposts, brakes, shifters and even stems. Any of these might end up needing an emergency replacement when you're the farthest from the road. M5 happens to be the size of your water bottle bolts. Throw the bottle in your pack or pocket and, if it’s long enough, you can use the bolt for something more life-or-death.
M6 bolts are used to mount your brake caliper to your frame or fork. They're also used for many saddle clamps or even some suspension pivot hardware. M6 also happens to be the size of your headset preload bolt. This seemingly crucial bolt is actually just there to adjust headset bearing. If your stem is tight, you can finish a ride without it. Replace it when you're done, but if you need it for something more crucial, it's up for grabs.