The Prophet Muhammad PBUH married his adopted son’s ex-wife because in Islam, an adopted child is not seen as your actual child. When the Prophet PBUH adopted Zaid, he named him Zaid Ibn Muhammad, but Allah did not condone this, because in Islam, the lineage of a person is protected. Later on, Zaid and Zainab chose to get divorced, and Allah enforced this idea even more (that your adopted son is not your actual son) by ordering the Prophet PBUH to marry her. This is why Allah mentions in the Quran, “And ˹remember, O Prophet,˺ when you said to the one for whom Allah has done a favor and you ˹too˺ have done a favor, ‘Keep your wife and fear Allah,’ while concealing within yourself what Allah was going to reveal. And ˹so˺ you were considering the people, whereas Allah was more worthy of your consideration. So when Zaid totally lost interest in ˹keeping˺ his wife, We gave her to you in marriage, so that there would be no blame on the believers for marrying the ex-wives of their adopted sons after their divorce. And Allah’s command is totally binding” (Quran 33:37). This is why the whole adoption system that one can see today and that was seen at the time of the Prophet Muhammad PBUH is totally against Islam, as it does not protect the lineage of the people. Therefore, Allah wanted to completely break this ideology and way of thinking by giving an example through the best man to ever exist, PBUH. Therefore, the claim that the Prophet Muhammad PBUH just had lust for women is a baseless claim. When the Prophet Muhammad PBUH was at his prime and youth, he only married one woman, and she was older than him, and he never even got married to anyone else until she passed away. After that, he married more wives but they were all for a specific beneficial purpose or reason.
And Allah knows best.