We get to choose which things we do today as in war, in some cases you kill every living thing and in other cases you kill just the soldiers. Jesus said many things in opposition to the old testament. There is a bit of nation building. Try for peace first. Then make sure everyone is really ready then go in and kill them. You don’t kill everyone who are a long way away because you need to maintain the supply line. Is this kind of war we waged against the Indians in the west. For close cities, you wipe out the people and their practice.
Chapter 21 has rules for how you treat the vanquished. The rules for the body that were made were about purifying the ground. They assumed that a body would be from the closest town. There was no compassion for the body, but purify the people who found it and purify the ground.