The M4 is an M16 in carbine form (14.5" barrel) with a collapsing stock, the carry handle on top replaced with a Picatinny rail (usually - older versions don't have this, current production does), and a two- or three-rail fore-end for accessories. It's a later development of the old CAR-15.
M4, older model on bottom:
M16/AR15 (A4 variant):