The sentence of death in this case was not against age and gender, but against disloyalty and betrayal of the true God. Groups that had participated in baiting Israel toward religious diversity (Israel’s paramount stumbling blocks) received the captial sentence, while groups that had not (prepubescent femalse in this case) were spared.
Modern just-war theory requires that violence be restricted to combatants, that harm be directed against military targets (not civilian populations), and that the least possible damage be inflicted to achieve legitimate military objective. These ideas have firm grounding in biblical principles of justice and fairness, though some Christians believe even just-war theory is wrong since it sanctions killing. War, justice, and morality had different configurations in ancient times. The nation of human rights was dimly perceived through the general fog of international distrust and pagan worship, (Imagine your regard for human life if you believed that all gods were wicked, cruel, and jealous.) Gradually, the loving character of the true God came to be seen and understood through the psalms, prophets, and later the preaching of the gospel.
NUMBERS 31:17 – 17 Now therefore kill every male among the little ones, and kill every woman that hath known man by lying with him.