M4 bolts are usually used in most of the bikes. M5 Bolts are little heavier compared to M4, it can bear more load due to the increased diameter of the bolts.
Different manufactures use them according to the load calculations. M5 bolt is 1 mm thicker compared to M4 and can bear more stress and load during races and events.
M stands for metric So M5 bolt says, it’s outer diameter is 5mm, and M4 bolt’s outer diameter is 4mm. These bolt name describe, these spares are rated in metric units to avoid confusion.