First I want to thank you for your service. War is never pretty. God takes no pleasure in the death of anyone.
Now, my example is not about the granular "gray areas", but instead to the specific and clear areas where we all can agree it is justifiable. In general, as a society, we have all agreed that Hitler deserved the death penalty. Everyone understands that there is not much of a choice but to remove by any means necessary, even death.
With that framework in mind, when God does this, He gives the people plenty of opportunities to change. When Moses was ordered to eliminate certain towns, it was because judgment had been passed. The people God had judged were the most detestable pagans you can imagine. Offering child sacrifices to their gods. They were people, just as cruel as Hitler. God gave them over 400 years to change, but they preferred evil over good.
Therefore, there is no question about Gods justice. These were people who were as lawless as you can get.