Screws usually end up different lengths and sizes for ordinary mechanical reasons (meaning, for example, if the screw was 0.5mm longer, it would interfere with something else).
The harder you are working to make the smallest thing possible, the more this happens.
Additionally, since no one has half a million 2.32mm long M1.2 screws just lying around, they're always a custom order. Might as well get the exact length you want.
In the iPhone, for example, each screw gets its own part number and each screw is custom.
Your assembly automation also affects screw choice. Some screw heads register better/faster than others depending on the size. This affects your line speed. A line might also be building sub-assemblies that are shipped to different lines with different equipment and this a whole different set of optimized part sizes.
The order you repair something isn't necessarily the order it was assembled in the factory(ies).
Yeah having worked for an electronics manufacturer they really really want to standardise this stuff where possible because every screw is a critical component and having many different types it means you can have many different chances to run out of stock and interrupt production. It also makes the manufacturing line more complex and training longer.
But in many cases there's just specific needs. Besides length, exterior screws are often countersunk, while internal ones would have flat heads to distribute the pressure over a PCB.
When it comes to stopping customers fiddling with the equipment look at Nintendo that use a different proprietary screw head for everything.
Who doesn't love how HDDs and optical drives use different screw sizes. Plus one is imperial and the other is metric. Maybe we should just feel lucky they standardized at all.
The harder you are working to make the smallest thing possible, the more this happens.
Additionally, since no one has half a million 2.32mm long M1.2 screws just lying around, they're always a custom order. Might as well get the exact length you want.
In the iPhone, for example, each screw gets its own part number and each screw is custom.