Personally, I do not think that God ever ordered any massacres. but maybe there are some elements worth considering.
The idea of killing children is disgusting, but I think that, even if the children would have been spared, they would have had no hope to survive without men’s help and protection. Once the men had been killed, women and children would have been doomed to die of hardship or to be killed because of raids by some other tribes.
So, directly or indirectly, killing the men would have killed also the children.
We are talking about violent and warmongering peoples.
In 1 Sam 15 , Samuel orders the jews not to spare cattle; however, the jews kill everybody, but they disobey this oder and spare cattle (because the cattle was very useful to them, of course). This clearly proves that the jews did what they did (i.e. the massacre of men, women and children) because the WANTED to do that, and not because they wnated to obey a divine order.
Samuel’s words do not seem to be a real order but a prophecy, such as: you will attack, you will win, you will kill everybody. The order to kill the cattle is the litmus test, which shows that the real intentions of the jews were not to obey God, but to appropriate their goods.