Let me explain. This is something that actually happened, in World War One; Jews volunteered to fight with the Entente and many Jews volunteered on the Central Powers. Some could have served on the same fronts. What would Halacha’s opinion on this be? Should I serve and fight for what I think is the ‘greater good’ for the Jewish people, like the allied Jews did, or serve for whatever I thought the greater good was as the German Jews had, or not serve at all? Most importantly, if I did serve, would I be חייב מיתה?
If the cause of your country is justified, you should fight. When countries are at war, individuals by necessity are subordinate to the national cause. See War and Peace.
Having said that, very often the cause for war has not been at all justified. The only measure we have for this is the acceptable norm at the time, which is not always easy to define.