The Gemara in Yevamos 42 a-b says that the sages decreed that a pregnant woman or a nursing mother can't marry because if she's nursing and gets pregnant again, she will not be able to produce milk to feed the older baby, and if she's pregnant she can't marry because her new husband may injure the fetus during marital relations, and the father of the fetus has an interest in the fetus. (I'm skipping a few details because it's not our issue.)
Rambam paskens in Geirushin 11:25:
כד המארס בתוך תשעים יום, מנדין אותו; אירס וברח, אין מנדין אותו. כנס בתוך תשעים יום, מפרישין אותן עד אחר הזמן; ויעמוד עם אשתו.
כה וכן גזרו חכמים שלא יישא אדם מעוברת חברו, ומניקת חברו, ואף על פי שהזרע ידוע למי הוא: מעוברת--שמא יזיק הוולד בשעת תשמיש, שאינו מקפיד על בן חברו; ומניקה--שמא יתעכר החלב, והוא אינו מקפיד לרפאות החלב בדברים המועילין לחלב כשיתעכר.
כו כמה הוא זמן היניקה--ארבעה ועשרים חודש, חוץ מיום שנולד בו ומיום שתתארס בו. [כז] כשם שאסור לישא, כך אסור לארס עד אחר זמן זה; ואפילו נתנה בנה למניקה, או שגמלתהו בתוך ארבעה ועשרים חודש--לא תינשא; מת בנה--מותרת לינשא, ואין חוששין שמא תהרגנו.
So: a woman always needs 3 months, actually 94 days, between being divorced or widowed and getting remarried. If she became pregnant from the first (or earlier) husband, her pregnancy will be noticed by 3 months, and that husband is the child's father, and if she is not pregnant by then, if she has a baby, even if it is born early, at 6 or 7 months, we will know it is from the second (or later) husband, since she was not pregnant at the time of the wedding.
If, upon divorce or after her husband's death, she is pregnant, or if she is nursing (until the baby is 24 months old), she cannot remarry. This is a Rabbinic decree. (I know that the Rabbanut in Israel, if they issue a get and the couple has a child under age 2, they document that the woman cannot remarry until that child reaches age 2.)
Shulchan Aruch also paskens this in E"H 13:11.
In this situation, where the woman is pregnant, if the woman becomes pregnant again after giving birth to the child she is currently carrying, she will not be able to produce milk to nurse the baby. For this issue, Rav Ovadia Yosef said they can feed baby formula to the baby. (While this option was not available in the time of the Gemara, there is a discussion about hiring wetnurses.)
This solves the meinekes issue. But how does it help the other issue in this case how can they get married because she is pregnant, and therefore they can't have relations lest the baby be harmed? The Pischei Teshuva there says: if a woman conceived artificially (b'ambatya), see Birkei Yosef. He does not say what Birkei Yosef says.
But we see a point: where the woman underwent IVF with semen from a sperm bank, and not from a husband, there is a biological father, but in the legal framework, it is almost as if there is no father. In that case, does the Rabbinic decree still apply?
Even though I don't know what the Birkei Yosef says, the Otzar Haposkim (os 71b) mentions other shitos who do weigh in on this matter:
Toras Chesed (by R'S"Z MiLublin) 13 says as a simple matter that she may marry because the Sages did not make their decree in an unusual case like this [meaning insemination without bi'ah]. However, Kerem Shlomo E"H (to R"Sh. Ha'elm) says that when the Sages made the decree, they made a blanket decree and it applies even in an unusual situation.
So the easiest way to understand Rav Ovadia Yosef's psak - I have not seen a teshuva, so I am only speculating on his reasoning - is like the Toras Chesed, that the Sages did not make their decree in an unusual situation like this.
Another explanation, though much more far-fetched, is along the same lines: we can say that the decree wasn't a blanket decree, it only applied when the rationale for such a decree applies: not harm the unborn child of Mr. Ex-Husband. But here, there was no husband and there was no bi'ah, the Tzitz Eliezer has a possibility that for such a child there is no halachik father. It is very difficult, and I have no reason to suspect Rav Ovadia Yosef would accept this even for a ruling like this, but if there is no father, there is no reason to make the decree in this situation.