The idea of God commanding the Israelites to carry out military campaigns and to destroy all the inhabitants, including women and children, is found in several passages of the Old Testament. One example is the conquest of Canaan, which is described in the book of Joshua.
In Joshua 6:17-21, God commands the Israelites to destroy the city of Jericho and to kill every living thing in it, including men, women, children, and animals:
"And the city and all that is within it shall be devoted to the Lord for destruction. Only Rahab the prostitute and all who are with her in her house shall live, because she hid the messengers whom we sent. But you, keep yourselves from the things devoted to destruction, lest when you have devoted them you take any of the devoted things and make the camp of Israel a thing for destruction and bring trouble upon it. But all silver and gold, and every vessel of bronze and iron, are holy to the Lord; they shall go into the treasury of the Lord.” So the people shouted, and the trumpets were blown. As soon as the people heard the sound of the trumpet, the people shouted a great shout, and the wall fell down flat, so that the people went up into the city, every man straight before him, and they captured the city. Then they devoted all in the city to destruction, both men and women, young and old, oxen, sheep, and donkeys, with the edge of the sword."
Similarly, in Deuteronomy 20:16-18, God commands the Israelites to destroy all the nations that they conquer, leaving no survivors:
"But in the cities of these peoples that the Lord your God is giving you for an inheritance, you shall save alive nothing that breathes, but you shall devote them to complete destruction, the Hittites and the Amorites, the Canaanites and the Perizzites, the Hivites and the Jebusites, as the Lord your God has commanded"
It's important to note that these passages are often understood in the context of God's judgment against the nations for their wickedness and idolatry. The nations that were destroyed were not innocent victims, but rather were guilty of great sin and rebellion against God. For example, in Deuteronomy 9:4-5, God tells the Israelites that it is not because of their own righteousness that they are taking possession of the land, but rather because of the wickedness of the nations that are being driven out:
"Do not say in your heart, after the Lord your God has thrust them out before you, ‘It is because of my righteousness that the Lord has brought me in to possess this land,’ whereas it is because of the wickedness of these nations that the Lord is driving them out before you."
Additionally, it's worth noting that the language of destruction in the Old Testament may not always be meant to be taken literally. Some scholars argue that the descriptions of total destruction may have been hyperbolic language used to emphasize the seriousness of the situation and the need for complete separation from idolatrous practices.