How has it EVER been legal to buy an Assault Rifle?

assault rifle used in orlando shooting

I am not a gun Person but I understand the second amendment. I have no problem with guns in the hands of responsible owners that want to protect themselves. But I cannot understand How and When assault rifles were legalized. What is the point of this gun? You cannot hunt with it and if You tried to use it inside Your home, it would be highly cumbersome against a hand gun. It is not a weapon that You want to use at close range because of the length of it. It seems to have no reason to be used except in a military or police operation. What do the gun rights People say? That there are other assault rifles out there so they need one to counteract them? Is that reasonable? The assault rifle needs to be banned and all the ones currently in the hands of the public must be turned in. The owner could get  money for His gun at an amount determined by a private third party, these guns could be used by the military. Anyone caught with one of these rifles should be convicted of a felony punishable of up to 10 yrs in prison, not for using it just for possession. For firing an assault rifle should bring minimum of 20 years and injuring a Person, 30 years, killing a Person, life without parole. It would take many years to get all the assault rifles off the streets but there is no better time to start than NOW. Offer rewards to Anyone knowing of a Person in possession of an assault rifle would surely speed the process up.

according to Wikipedia the second amendment goes like this:
A well regulated militia being necessary to the security of a free State, the right of the People to keep and bear arms shall not be infringed. On December 15, 1791, the Bill of Rights (the first ten amendments to the Constitution) was adopted, having been ratified by three-fourths of the states.

I do not think the 2nd amendment was meant to allow assault rifles.