God destroys an entire nation with children only in extreme circumstances. For example, when God was speaking with Abraham about His plan to destroy Sodom and Gomorah, He promised to not destroy the cities if He found at least 10 righteous people in them. There were children in Sodom and Gomorah too. Apparently, not even children in those cities were righteous. Children often follow sins of their parents. And evil tends to corrupt the society more and more with time. The more sinful people are there around you, the harder it is to not be sinful. People like to follow the crowd. Children like to follow their parents. At a certain point, evil becomes so prevalent in a society, that no matter how many children are born, they will all be sinners. When God forsees that a nation has reached that point, when even none of the children who could be born in this nation would be rightous, he has no choice but to destroy that nation completely. Otherwise, that nation will spread evil to other nations. It’s these extreme interventions of God that prevent complete moral decay of the human race.
The nations of ancient Palestine that lived there before Israelites were extremely sinful. Even our perverted mainstream TV would not dare show some of the things they did when documentaries are done on these nations. And yet God gave them 400 years to repent. Actually, when speaking to Abraham, God said He would give them 400 years. In reality, the nation of Israel took the land after 430 years. So God gave them 30 more years than He originally planned, maybe in the hopes that a new generation of children would be better. But in extremely corrupt societies, children grow up been used to living a sinful life. So if God spared the children, they would grow up to be just like their parents.
As far as really small children go, who could not tell right from wrong, it was actually better for them to die in this world young and not be judged in the future world. Since God does judge only children who were old enough to make a choice.