Can a civilian buy a military weapon?

Unfortunately not legally. a Civilian can buy a weapon similar to one that is issued to soldiers. For example: The equivalent of the M-16 is the AR-15. some differences is that the AR-15 is not fully automatic and dosent have a 3 round burst option. it wont be specially customized like military does.
Somethings you can do if you want a fully auto rifle is buy one that was made prior 10 1986. then bring it to someone that handles rifles and they can add a few parts and alter the configuration. this is very costly though.
you can get one illegally through the black market. but it isn't worth it because you cant show anyone or enjoy it in public

It depends on where you are and exactly what you want. In some parts of the world civilians seem to have access to weapons as large mortars and rocket propelled grenades and all kinds of full-auto weapons. In most of the US, you can buy surplus military rifles and handguns. Even full-auto weapons can be purchased if you have the proper license and follow all of the BATF rules.