The Second Amendment protects the right of the people to keep and bear arms, yet it is illegal to own some weapons. How can this happen?

A right to public safety is guaranteed in the Constitution.
The United States is not threatened by invasion in modern times.
States and local governments can make laws restricting weapons.
Modern weapons are more dangerous than the ones from the Constitutional era.