Your first sentence suffers from the limitations expressed in your second sentence.
The 2A is there to allow citizens to defend themselves, period. Whether from foreign invasion, local goblins and perps, or from the Armed Forces of Janet Reno and Hildebeeste.
Thanks for correcting my omission. The second amendment addresses a fundamental human right: self-defense from all threats, be they foreign, domestic; or be they criminal, military, or political. There must be no compromise on any of these principle justifications for remaining armed. No retreat!