How could God say, “Thou shalt not kill,” but then command the Israelites to kill those who did?
The word “kill” is actually the Hebrew word for “murder.” The command is, “Thou shalt do no murder.” Killing of any kind is not what is forbidden, only actual murder. For example, Genesis 9:6 states, “Whosoever sheds man’s blood, by man shall his blood be shed.” The same principle for today is given in Romans 13:1-4. In John 19:10-11 when Pilate told Jesus that he had the power to put him to death, Jesus responded that he would not have this power if it were not given him by God. Man, by some governing authority, is under the responsibility to put to death the murderer. Therefore, God is not forbidding the taking of a life under all circumstances, but in unauthorized circumstances. When God commanded Israel to destroy all in the land of Canaan, He was pronouncing the death penalty on a nation that had practiced things worthy of death under God’s law. Israel, was God’s authorized instrument to carry out the death penalty. Thus, there is no contradiction.