It doesn't.
It states, "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.
You keep leaving out the first part in order to make your point. If the amendment left out the first part, then I'd agree with you. It doesn't, and you shouldn't either.
But it's there, and because it's there, it ties the RKBA to a well regulated militia and to the function of keeping the state free. Since we now have a standing army and we no longer have the type of well regulated militia we once had, I really don't know the standing of the second amendment.