Praise be to Allah.
If a man divorces his wife with a third talaaq, she does not become permissible for him until she has married another husband in a genuine marriage, not a tahleel marriage [a short-term marriage solely for the purpose of making it permissible for the woman to go back to her first husband], then he dies, leaving her a widow, or he divorces her, because Allah, may He be exalted, says (interpretation of the meaning):
“And if he has divorced her (the third time), then she is not lawful unto him thereafter until she has married another husband”
Al-Bukhaari (2639) and Muslim (1433) narrated from ‘Aa’ishah (may Allah be pleased with her) that the wife of Rifaa‘ah came to the Prophet (blessings and peace of Allah be upon him) and said: I was married to Rifaa‘ah, then he divorced me and made the divorce irrevocable. Then I married ‘Abd al-Rahmaan ibn al-Zubayr. He said: “Do you want to go back to Rifaa‘ah? No, not until you taste his (‘Abd al-Rahmaan’s) sweetness and he tastes your sweetness.”
Muslim (1433) narrated that ‘Aa’ishah (may Allah be pleased with her) said: A man divorced his wife three times, then another man married her and divorced her before consummating the marriage with her. Her first husband wanted to remarry her, and the Prophet (S) was asked about that. He said: “No, not until the second husband tastes of her sweetness what the first one tasted.”
What is meant by the words “he divorced me and made the divorce irrevocable” is: he issued me a divorce that put a final end to my marriage to him, which is the third talaaq.
What is meant by the words of the Prophet (blessings and peace of Allah be upon him) “until you taste his sweetness and he tastes your sweetness” is a metaphor for intercourse.
An-Nawawi (may Allah have mercy on him) said: This hadith indicates that a woman who has been thrice divorced is not permissible for the husband who divorced her until she marries another husband and he has intercourse with her then leaves her, and her ‘iddah comes to an end. As for merely doing the marriage contract with her, that does not make her permissible for the first husband. This is the view of all scholars among the Sahaabah and Taabi‘een, and those who came after them.
End quote from Sharh Muslim (10/3)
Tahleel marriage is a marriage in which a man marries a woman for the purpose of making her permissible for her first husband, then he divorces her. It is prohibited and invalid according to the view of most of the scholars, and the woman does not become permissible for her first husband thereby.
This applies whether this aim is explicitly expressed at the time of the marriage contract, and they stipulate that when he has made her permissible for her first husband he should divorce her, or they do not stipulate that and he merely intends it in his own heart.
See: al-Mughni (7/574)
Abu Dawood (2076) narrated that the Prophet (blessings and peace of Allah be upon him) said: “May Allah curse the muhallil and the muhallal lahu.” Classed as saheeh by al-Albaani in Saheeh Abi Dawood.
The muhallil is the one who marries a woman in order to make her permissible for her first husband. The muhallal lahu is the first husband.
Ibn Maajah (1936) narrated from ‘Uqbah ibn ‘Aamir (may Allah be pleased with him) that the Prophet (blessings and peace of Allah be upon him) said: “Shall I not tell you of a borrowed billy-goat.” They said, Yes, O Messenger of Allah. He said, “He is al-muhallil. May Allaah curse al-muhallil and al-muhallal lahu.” Classed as hasan by al-Albaani in Saheeh Sunan Ibn Maajah.
‘Abd ar-Razzaaq (6/265) narrated from ‘Umar (may Allah be pleased with him) that he said, when addressing the people: By Allah, no muhallil or muhallal lahu will be brought to me but I will stone them.
The tahleel marriage is invalid.
Ibn Qudaamah (may Allah have mercy on him) said: The marriage of the muhallil is invalid and all the rulings on invalid contracts are applicable to it. No chastity could be attained by that and it does not make the woman permissible for the first husband, as is the case with all invalid marriage contracts.
End quote from al-Mughni (7/574)
Based on that, this marriage is as good as non-existent, so if the second husband divorces you, he does not have the right to take you back, because the right to take the wife back can only be based on a valid marriage.
But if you want to marry this man (the second husband), let him do a valid marriage contract with you, in a genuine marriage, not a tahleel marriage. And you both have to repent from what you previously did of a haraam marriage.
If this valid marriage is done, it will not be a tahleel marriage.
If it so happens that the second husband dies or divorces you, then you will become permissible for the first husband.
And Allah knows best.