It also puts you into the position to think about using it for anything other than defence. (I.e. the position of having a hammer and searching for nails.)
I think it is every person's teleological purpose to contribute to the general welfare of humanity. As such, I do not agree that the purpose of a military is for defence. I think the purpose of a military is to contribute to the general welfare of humanity.
But independent of the unethical way you got into the position of deciding to attack an other country for "ethical" reasons,
Unethical according to which system of ethics?
you also have to question yourself whether you want to grant that right to other players who might have other moral principles. If your country isn't fairing that well on human rights at the moment, would you want to be attacked by your neighbour who is just helping you to be more moral? Or, in other words, is your attack war justifiable by the Golden Rule?
I am willing to sacrifice my life for the greater good, yes. I have already risked death to save the lives of other people a few times, expecting to not survive.
However, it is true that I might think somebody is wrong to think that their actions are serving the greater good. On those grounds, I wouldn't even support unethical actions that do not directly affect me.
That said, I think the Golden Rule is unethical and it is not a heuristic that I hold myself to.