In line with the context of the OP, and being that this is as
@cvanwey says a "particular case," I think there is another but still related reason which prevented the young Midianite boys from being spared.
To my mind, that reason is that the tribal sector of Midianites mentioned in Number chapter 31 relinquished their status of privilege when they schemed against the people of Israel and were then classified and relegated to the same low status already had by the several Canaanite nations who were condemned to suffer the fate of "Yahweh warfare," or
Harem. These particular Midianites became a tribe of those "near" rather than "far off," and thus the little boys, unfortunately, were not to be spared either.
This is my thinking as I've considered the various relevant texts hermeneutically myself, as well as conferring with Paul Copan & Matthew Flannagan in their book,
Did God Really Command Genocide?: Coming to terms with the justice of God (2014), among some other sources.