Unreflective people will have a hard time doing this. They will say the enemy kills innocent people because the enemy is "evil" and that the deaths of innocent people killed by our side is actually the enemy's fault because we only killed them because we are fighting "evil." Now apart from the illogic here and the fact this is name-calling masquerading as explanation, there is also a false assumption at work--that "good" and "evil" refer to different types of people. As Alexander Solzhenitsyn points out, "The line separating good and evil passes not through states, nor between classes, nor between political parties either--but right through every human heart."
Moving up the developmental scale, reflective people will realize that something more is needed to explain the righteous killing of innocents than simply dividing the killers into "good" and "evil." Aware that those who are deemed terrorists in one frame of reference are often called freedom fighters in another, they will see how the offender is often motivated by a sense, however twisted, of retributive justice. Thus the reflective person will try to understand the anger and desperation that shapes the offender's thinking.
Of course, unreflective people will then typically mischaracterize these thoughtful attempts to understand what an offender was thinking as constituting approval for what the offender has done. For example, in the aftermath of 9/11, those who attempted to understand what motivated the attackers were accused of agreeing with them.
Continuing up the scale, a deeply reflective or philosophical person will go even further, not just trying to understand what the offender was thinking, but also working backwards in the manner of a "conceptual archeologist" in order to identify the unconscious assumptions that structure the offender's worldview. What is revealed is that those who think God commands these monstrous acts are working from a questionable assumption about the nature of God.
In the Medieval period questions both about the nature of God and the source of our knowledge of goodness were debated in great depth. Thomas Aquinas argued that we have available to us two independent ways to know how to act--the findings of natural reason and the revealed word of God. Of course, there was further debate revolving around the interplay of faith and reason. The debate often centered on this pivotal question: does God command only what is "good" (meaning that everything God commands also always aligns with reason and natural law)...or is "good" simply what God commands (meaning that reason and natural law do not apply to God's commands)?
To an unreflective person these two--"God commands what is good" and "good is what God commands"--seem identical. In truth, however, they make dramatically different assumptions about the nature of God. In the first (God commands what is good), the emphasis is on God's supreme goodness. Accordingly, God will necessarily conform to the laws of natural morality because they are extensions of his own nature. In the second (good is what God commands), the emphasis is placed on God's all-powerful will. And when a person thinks God's will takes priority over everything else, even goodness, then the will of God does not need to conform to the laws of natural morality. Interestingly, all killing in the name of God--every act of terror, each crusade, and all holy wars--is based on this assumption that God's will takes precedence over God's goodness.
Once again, as Thomas Aquinas explains, if God commands only what is good, then we have available to us two independent sources about how we should act--the commandments of God as revealed in Scripture and the strictures of natural law as revealed by reason. Accordingly, we can be certain that any action that violates natural law and offends common decency, like setting off car bombs or torturing prisoners, cannot be sanctioned by God. And if the action is supported with scriptural references, it means Scripture is being misunderstood or misapplied.
The situation is just the opposite if good is what God commands. Here, since "good" means what God "commands," we cannot use reason, natural law, or common decency to evaluate God's commands. Indeed, if we believe God commands it, then by definition it is good--even if it is odious to morality, decency, and civilized values. This is why Voltaire said that if someone can get you to believe absurdities (that God wants you to terrorize, torture, and kill certain people), then they can get you to commit atrocities (to actually torture, terrorize, and kill them).
So how can people commit atrocities and think they are serving God? First, they have to assume that God's will is more important than God's goodness, and then they have to believe, often on the basis of deeply misunderstood passages cherry-picked from Scripture, that God wills these atrocities to be committed.