Oh, my- where to start?
First, the AR-15 is actually a brand name. It usually denotes the full sized rifle. The military caliber is 5.56mm, which is SIMILAR to, but not the same as .223. You can shoot .223 in a 5.56, but shooting 5.56 in a .223 MAY give high pressure- bad ju-ju. The AR STYLE rifle is made in a VARIETY of calibers, ranging from .22 LR to .50 Beowulf. .308 and .243 are popular, as well as some of the 6mm rounds. Within limits of case length, you can also switch uppers, having multi-caliber capabilities from one lower.
M4- term USED to denote the shorter carbine, usually with a collapsable stock. The TRUE M4 is not available to civilians in the US, since it has a burst fire or full auto mode, and was made after the 1986 full auto transfer ban. The lookalikes are semi, and simpler a shorter rifle, little handier in close quarters, a little slower bullet due to shorter bbl.
M16- the military, full auto version. Due to the 1986 transfer ban, price on a legal, transferrable full auto M16 will make you weep. Last one I saw was about $12,000, plus the $200 transfer tax. Do not even THINK about converting a semi to full auto- you need a machine shop, and in the US the penalty for making an unregistered machinegun is 10 years in a Federal prison, a $250,000 fine, and loss of your girlish laughter.
You could have a HUGE rifle collection with nothing but variations of the AR style rifle- different calibers, different barrels, different sights, different actions, different materials- left handed models, even AR style pistols- and there are now gas piston (instead of gas tube) models. The variations would make a BIG book- I have just scratched the surface in this post.