It's quite obvious when it comes to combatants, but what about non combatants? One interesting and fair answer I got is since women and children are likely to lose their husband in war or see him taken as a captive, there would be nobody left to support them and it would only be reasonable to also take them alongside the combatants. But what about the male civilians for example like farmers, elders etc who didn't not take part in war and that should not be killed according to many scholars. These would be able to get by on their own either way, so what could be one way to rationalize their enslavement?
Enslaving is just like taking POW (prisoners of war) in modern wars. It is upto the leader of army to take the decision on what to do with those captured. Their decision can be based on the collective good of the society, army and also the captured people.
But whatever the case we should be very kind towards the captured people
And if any one of the polytheists seeks your protection, then grant him protection so that he may hear the words of Allāh [i.e., the Qur’ān]. Then deliver him to his place of safety. That is because they are a people who do not know. Quran 9:6
And feed with food the needy wretch, the orphan and the prisoner, for love of Him, (Saying): We feed you, for the sake of Allah only. We wish for no reward nor thanks from you; Quran 76:8-9