The Jews warred against the Midianites, slew all the males. slew the kings - took all the women of Midian captives, and their little ones,
and killed every male among the little ones, and killed every woman that had known a man by lying with him.
But all the women children, that have not known a man by lying with him, They KEPT alive for Themselves...
................................
You should keep in mind that the Midianites were aggressors against the Hebrews. The Midianites JOINED Up with the Enemies of Israel who were trying to eXterminate the Hebrews
Please NOTICE in - Deu 25:17 Remember what Amalek did unto thee by the way, when ye were come forth out of Egypt;
Deu 25:18 How he met thee by the way, and smote the hindmost of thee, even all that were feeble behind thee, when thou wast faint and weary; and he feared not God.
Deu 25:19 Therefore it shall be, when the LORD thy God hath given thee rest from all thine enemies round about, in the land which the LORD thy God giveth thee for an inheritance to possess it, that thou shalt blot out the remembrance of Amalek from under heaven; thou shalt not forget it.
The Amalekites attacked the Hebrews from behind as they were escaping and moving away - from Egypt.
The Amalekites attacked the Weaker people who were = at the Rear of the traveling Jews, who were feeble faint and weary.
The Book of Psalms clarifies the environment and duties of the Israelites When they Go to war against their Enemies who had been attacking them.
Psa 83:4 They have said, Come, and let us cut them off from being a nation; that the name of Israel may be no more in remembrance.
Psa 83:5 For they have consulted together with one consent: they are confederate against thee:
Psa 83:6 The tabernacles of Edom, and the Ishmaelites; of Moab, and the Hagarenes;
Psa 83:7 Gebal, and Ammon, and Amalek; the Philistines with the inhabitants of Tyre;
Psa 83:8 Assur also is joined with them: they have holpen the children of Lot. Selah.
Psa 83:9 Do unto them as unto the Midianites; as to Sisera, as to Jabin, at the brook of Kison:
Psa 83:10 Which perished at Endor: they became as dung for the earth.
please Keep in mind that these Canaanites Attacked the Hebrews First and made war on them when they were traveling on their way from Egypt. They were trying to eXterminate them. So the Hebrews Won the War. Killed Everyone of them But were allowed to SAVE the VIRGIN Women who could be made into CLEAN future Wives for them.
The Hebrews did not Run around attacking people for no reason, Just to rape their women. PLEASE READ the FULL HISTORY