The second amendment guarantees states the right to form armed militias
The second amendment guarantees that the right of the people to keep and bear arms shall not be infringed. The purpose of that right is certainly because a well regulated militia is necessary to the security of a free state, but the right clearly belongs to the people and not the states (which do not have rights, but rather have powers). The power of the states to form militias is already articulated in Article I, Section 8.
It wasn't intended to give every individual the right to own guns for their own private use. That's a modern reinterpretation.
[citation needed]
The actual "modern reinterpretation" is that the second amendment is not an individual right. The first time the US Supreme Court referenced a right to bear arms was in its repugnant Dred Scott decision, where it held that black people could not be citizens because they would have the rights "to go where they pleased at every hour of the day or night without molestation, unless they committed some violation of law for which a white man would be punished; and it would give them the full liberty of speech in public and in private upon all subjects upon which its own citizens might speak; to hold public meetings upon political affairs, and to keep and carry arms wherever they went."
So, in 1857, we have a clearly established individual right to keep and bear arms (that, it being the antebellum US, we are denying to people because of their race. This is, thankfully, resolved by the ratification of the 14th amendment).