This is best explained if, initially, we ignore motorways altogether.
The Ministry of Transport (as it was then called) numbered six key roads radiating out from London, reading clockwise, as A1, A2, A3, A4, A5 and A6. (A similar system was used in Scotland, with the A7, A8 and A9 radiating out clockwise from Edinburgh).
All A roads on the clockwise side of the A1were numbered with '1' as the first digit. The most important roads were given two digit numbers and followed the clockwise numbering system. e.g. the A10, A11, A12, and A13 are all to the clockwise side of the A1 and appear in a clockwise order. Then further subdivision occurred, with more minor roads on the clockwise side of the A10 being labelled as A100, A101, A102 etc. Lastly a final subdivision was used, with roads on the clockwise side of the A100 being labelled A1001, A1002, A1003, etc. B roads (and, indeed C roads, which appear on local authority plans) are numbered to fit in with the same system.
Obviously, the plan is imperfect because not all roads radiate out from London but it provides a basic numbering structure which is still used to this day.
When motorways were introduced, they were numbered to (roughly) fit in with the existing system. So the M1 is reasonably close to the A1, the M2 is fairly close to the A2, etc.
Chris