Can you explain the hadiths regarding having sex with captive women?
The hadith is about the expedition of Banu Mustaliq. According to Islamweb:
The following are the most important reasons behind this Battle
A- The tribe of Banu Al-Mustaliq supported Quraysh and joined it during the Battle of Uhud against the Muslims. It was among the block of Ahaabeesh tribes who participated in the battle supporting Quraysh.
B- The tribe of Banu Al-Mustaliq governed the main road leading to Makkah. It was a strong barrier that prevented the Muslims from reaching Makkah.
C- News came to the Messenger of Allah sallallaahu alayhi wa sallam ( may Allah exalt his mention ) that Banu Al-Mustaliq were mobilizing an army to fight him under the leadership of Al-Haarith bin Abi Dhiraar. Having heard about that, the Messenger of Allah sallallaahu alayhi wa sallam ( may Allah exalt his mention ) set out and met them in one of their watering areas called Al-Muraysee‘ in the direction from Qadeed to the sea coast. The Prophet sallallaahu `alayhi wa sallam ( may Allah exalt his mention ) made them taste a bitter defeat there.
Around 200 families were taken captives. The women were the family members of the adversaries of Muslims and were distributed to Muslim fighters. The daughter of the chief of Khuzaa was captured in that battle and she later married the prophet (and no one forced her. She willfully consented to the marriage). Her family wanted to take her by giving ransom but she refused and stayed with the prophet and accepted Islam.
I don't understand that if the Muslims had just won a battle and killed the captive's husband, brother, son or other relatives or the men of her village why would she be ready and willing to have sex with the victors?
We don't have much information regarding the consent of the captive women but there are reports that indicate that the woman who married the prophet consented to the marriage.
And only the fighting men were killed. Those who didn't fight were taken captives. This hadith is often used by the critics of Islam to accuse Islam of supporting rape which is not true.
Raping in the battlefield is haram and punishable. It was forbidden to have sex with them until they were distributed and their iddah period was over (that's a long time). The prophet said regarding the treatment of captives:
Allah has put them in your care, so feed them with what you eat, clothe them with what you wear. and do not burden them beyond their capacities; but if you burden them (with an unbearable burden), then help them (by sharing their extra burden).
The Quran prohibits forcing captives to have sex:
But let them who find not [the means for] marriage abstain [from sexual relations] until Allah enriches them from His bounty. And those who seek a contract [for eventual emancipation] from among whom your right hands possess - then make a contract with them if you know there is within them goodness and give them from the wealth of Allah which He has given you. And do not compel your slave girls to prostitution, if they desire chastity, to seek [thereby] the temporary interests of worldly life. And if someone should compel them, then indeed, Allah is [to them], after their compulsion, Forgiving and Merciful. [24.33]
And classical Muslim scholars also enforced harsh punishments for those who committed rape:
In Islamic military jurisprudence, classical jurists laid down severe penalties for rebels who use "stealth attacks" and "spread terror". In this category, Muslim jurists included abductions, poisoning of water wells, arson, attacks against wayfarers and travellers (highway robbery), assaults under the cover of night, and rape. The punishment for such crimes were severe, including death, regardless of the political convictions and religion of the perpetrator.
Also, captives had freedom of movement and the freedom to complain if their masters treated them badly.
'Umair, the freed slave of commanded me to cut up some meat, then a poor man came so I gave him some. When my master fund out about that, he beat me, so I went to the Messenger of Allah and he came to him and said: 'Do not beat him.' He said: 'He gave away my food without me telling him to.' He said: 'The reward will be shared between you both."'
It is important to note that many of the fighters weren't Muslim.
Many hypocrites went out with the Muslims to the Battle of Banu Al-Mustaliq even though they had often refrained from participating in previous Battles. Nevertheless, when they saw the Muslims win one battle after another, they joined them craving the booties.