https://constitution.org/1-Constitution/2ll/schol/2amd_grammar.htm
Here is a good analysis showing why the “right of the people to keep and bear arms” is not dependent on the militia at all. Also lays out why, in the sentence structure, the right of the people already exists and is not granted. You have that right at birth.
The militia and the security of the state are mere byproducts of something that already exists.
I believe it is another check and balance although the author does not go into that.
Enjoy!