Here is an answer extracted and expanded from my article, Is Sex Before Marriage Forbidden in the Bible?
If a man raped a woman who was pledged to be married, he was subject to the death penalty, while the woman was not to be punished at all:
But if the man meets the engaged woman in the open country, and the
man seizes her and lies with her, then only the man who lay with her
shall die. You shall do nothing to the young woman; the young woman
has not committed an offense punishable by death, because this case is
like that of someone who attacks and murders a neighbor. Since he
found her in the open country, the engaged woman may have cried for
help, but there was no one to rescue her. (Deuteronomy 22:25–27).
What if the woman was neither married nor pledged to be married?
In that society, it was assumed that an unmarried woman (who wasn't a prostitute) would not allow a man to have sex with her, because the consequences for her would be catastrophic. So if an unmarried man did have sex with an unmarried woman, unless there was some proof otherwise, it was considered rape, and the man was to be punished for it—but not by the death penalty:
If a man meets a virgin who is not engaged, and seizes her and lies
with her, and they are caught in the act, the man who lay with her
shall give fifty shekels of silver to the young woman’s father, and
she shall become his wife. Because he violated her he shall not be
permitted to divorce her as long as he lives. (Deuteronomy 22:28–29)
In other words, the man was subject to a large fine payable to the woman's father (which was basically a bride price) and to the ancient Hebrew equivalent of a shotgun wedding, from which he could not escape through divorce.
So it could be said that "the woman needs to marry the one who raped her," but that's not how it is framed in the Bible. Rather, the rapist was required to marry the woman.
This was based on a very different social order than exists in the West today. In ancient times, an unmarried woman who was not a virgin was subject to the death penalty if she married and it was discovered that she was not a virgin (see Deuteronomy 22:13-21).
The requirement that a rapist marry the woman he raped if she was not married or engaged to be married, as horrible as it seems by today's standards, was actually intended as a protection of the woman. It required the man who took her virginity to become her husband, and thus make her an honorable woman in the eyes of society, as well as requiring him to support her and her children for the rest of his life. It deprived him of the right he would otherwise have, under the law of Moses, to divorce her if he found her displeasing.