If my knowledge is correct, the U.S. military assigns a weapon series a number and then gives the next number to the next series of weapons.
For example, the military adopted the M-1 carbine. After a selective fire version came out, they designated it the M-2 carbine. The one after that had an infrared scope, so they called it the M-3 carbine. Then the military needed a shorter M-16, so they made a new carbine and called it the M-4 carbine. Why doesn't the same apply to rifles?
It isn't a very exciting answer, I'm afraid. In the old system, weapons were named for the year they came into use, like the M1903 carried in WWI. Later changes to the supply system adopted the somewhat sequential numbering, which is why you see so many M1s for different weapons (M1 Garand, M1 knife, M1 Abrams, ect...)
The nomenclature can vary among services, as well. For example, the Navy used MK for some weapons, and had an MK2 version of the Army called the M1.
As to the missing numbers, sometimes it's related to a weapon being approved but not adopted (like the M10 pistol). Generally those weapons are referred to as X(number)