Originally, the carbine was invented for cavalry use, since a shorter stock is easier to handle on horseback.
The M1 Carbine and similar weapons basically evolved into submachineguns - first the M3 "Grease Gun", then the M4 Carbine once the transition from battle rifles to assault rifles happened for front-line infantry.