It’s in the Constitution, the supreme law of the land, which applies in each of its fifty states.
The second amendment of this text, written in 1791, guarantees it:
« The right of the people to keep and bear arms shall not be infringed. »
It is specified that this allows the possibility of forming militias to defend, if necessary, the security of the state.
Indeed, a short time before, the Americans had a revolution to get rid of the English and founded a democracy.
This young country was afraid of having its hard-won independence taken away.
The right to bear arms to defend oneself is therefore, for many Americans, a guarantee of their freedom.
It’s also a symbol of heroism in American popular culture.