I don't consider myself part of a "nation" in the way you use it. Self-defense is important, but so are the lines that we choose to draw. If a superpower attacks the US tomorrow, I surely won't support the US army in anything that it does -- how could I, considering history? I just hope that someday, the US won't exist.
I agree with you, but the people invading aren't going to make that distinction, and they'll either consider you an enemy, or expect you to fight on their team; either way, you're dragged into the problem the minority created, without anyone's permission but their own.
Frankly, the only way to avoid this issue, as of today, is to not live in the country which is being invaded. If, in the future, we begin to assimilate and lose the borders, it becomes a lot more difficult to wage huge wars as we've done in the past, as it becomes painfully clear that the two warring parties are of the same kin--that is, they're both human beings first, as opposed to being, for example, Americans first and human second, or Chinese first and human second (ignoring how incredibly expensive it would be to wage wars in a voluntary society.) If the old adage is true, "United we stand, divided we fall," then this planet has no hope; it seems the end-game of politics, then, is either a one-world state, or no states; I'm personally rooting for the latter.
But that shift takes time, and until then, there will be people who want to kill other people for whatever silly reason, and the people being killed will have to defend themselves; a military is but an organized people with the intent or expectancy of violence.