It is written somewhere (I don't remember exactly where) that 40 days before conception, it is called out in Heaven who that person will marry. However, if the person gets married multiple times how does that work. Are the other marriages also called out? And what if the person doesn't get married?
Try this lecture from Rabbi Bednarsh, entitled "the theology of shiduchim." Not surprisingly, there are many different opinions.
The Gemara sounds like a first marriage is easy, because it's just the two people matching up as pre-destined. It's second (or later) matchmakings that are "as difficult as the Splitting of the Sea."
The approach that's easiest for me to understand is that which R' Aryeh Kaplan zt'l quotes in his book on marriage (I don't recall which Rishonim he's citing): at conception, it is most likely that Chaim Yankel will go about his life in such-and-such a fashion, and Zlota Shprintza will be the right person for him as their first marriage. (Now it's possible that G-d provided Chaim with Zlota's "shiduch resume" but he was too picky to consider it, or they saw each other someplace he was too nervous [or frum?] to walk across the room and say hello to her, and thus he's still single; that's Chaim's fault, not G-d's!) Both Chaim and Zlota, however, are able to exercise free will and dramatically change their trajectory of life, at which point their Divinely-set "bashert" is ... I guess the word is "recalculated."
In short, just because a couple should get married doesn't mean they will.
There's also some discussion about why you're allowed to get engaged during the Nine Days, "as if you don't get this great girl, maybe someone else will"; that would seem to imply that even if was bashert, there are no guarantees; but I've heard other explanations too.
See Sotah 2a (summarized here). The pre-conception designation applied only to a first marriage. In subsequent marriages, one gets what one deserves, which is harder for God to arrange than the Splitting of the Sea.
ארבעים יום קודם יצירת הולד בת קול יוצאת ואומרת בת פלוני לפלוני - סוטה ב א
Forty days before the formation of the fetus, a heavenly voices goes out and says "The daughter of so-and-so to so-and-so." - from Sotah 2a
At our siyum on Sotah, a speaker noted an answer offered by R' Yitzhak Aramah, the author of the "Akeidas Yitzchak". It can be found in the eighth "Shaar", on page פ"ב in the edition of the book found on HebrewBooks.org. He rejects that any match, even for a first marriage, could be preordained, since it would render meaningless the good deeds and prayers of the righteous as they strove to find suitable mates. (E.g. finding a wife for our forefather Yitzchak.)
רק כונתם במה שאמר כאן בזווג ראשון באן בזווג שני היא אל ב׳ מיני הזווגים אשר היינו עליהם כי הקודם מהם אצל הטבע והיא חבור החמר אל צורה הנמצא בכל איש ואיש שעליו נאמר זכר ונקב׳ בראם ויקרא אח שמם אדם הוא אשר קראוהו זווג ראשון.
which means, roughly, "rather, when they said 'one is for the first match, one is for the second match' their intention is to refer to two different kinds of matches which pertain to a person. The first of them is the connection of the Substance and the Form inherent in every person, as it is said, 'Male and female created he them; and blessed them, and called their name Adam [Genesis 5:2]' -- that's what we call the 'first match'."
His interpretation of the above was, which body does which soul get. That is preordained.
There is a contradiction between two sources. The Shulchan Aruch writes that one can get married on Chol Hamoed because another can beat him to her. Another says that the bas kol decides 40 days in advance.
One of the answers given is that one can get married before to someone not his bashert, but will later on marry his bashert. Another is that he is more "predisposed" to her, but he can still marry someone else.
A lot of this has already been covered in other answers here.
There are three statements the Gemara brings:
40 days before the fetus is formed a voice from heaven announced who the fetus will marry (Sotah 2a)
Matching up people is as hard for G-d (so to speak) as splitting the sea (Sotah 2a). Midrash (Bereishis Rabbah 68:1) elaborates that since the creation of the world, G-d keeps busy by making matches.
A man can betroth a woman on Chol Hamo'ed, since it is possible someone may "steal" him predestined wife through prayer (Moed Katan 18b). [A story is told there of someone who prayed to marry a certain woman, and later regretted it, and prayed for death - different commentaries give different interpretations of the story, if he got her or not, and who exactly he was praying should die, and why.]
The Talmud (Sotah 2a) reconciles the first two statements by saying that the first marriage is predetermined, and the second (and implicitly any subsequent match) is based on the persons deed (i.e. whether he is a wicked or righteous man he will get a wife he deserves).
The different interpretations of the story mentioned in number 3 have practical ramifications. Different commentaries have different opinions how successful a marriage will be if someone "stole" someone else's predestined bride through prayer, and interpret the story differently based on that.
There are Kabalistic, non-literal interpretations of what "First Marriage" and "Second Marriage" mean. by explaining the "first marriage" non-literally, they say that even the first time one gets married his spouse is determined according to his actions.
The Lubavitcher Rebbe was once asked how much of a person's choice in his spouse is free will, and how much is predetermined. In his response, the Rebbe lists 7 different opinions in Torah, ranging from fatalistic to Kabalistic, and then explains what Chabad Chassidic thought is on the matter.
Here is a bullet point summary of the different opinions, read the above links for more details and sources.
Sefer Chassidim - "stealing" someone spouse through prayer will only work for a short while. The marriage may not even be consummated.
Chida (1st interpretation) and Ran - "stealing" someone spouse through prayer will work for a while, but eventually the spouse will marry the one she was supposed to.
Rashi on Rif Moed Katan. - A heavenly voice decrees, but prayer can nullify the decree permanently , much like Leah's prayer permanently changed the boy she was going to have to girl (Dinah).
Tashbetz - Man can choose if he wants to get married or not, but once he decides to get married, he will marry the predetermined girl. Prayer will help like #2 above.
Rambam - the heavenly voice doesn't say this is who you will marry. Rather it says you will naturally be compatible with this person, but you could marry anyone you want. (This would theoretically apply to your second marriage, but by then your deeds determine who you will marry)
Akeidah - G-d predetermines which (what kind of) body your soul will go in (This is called the "First Marriage"). Actual marriage, even the first marriage, is called the "Second Marriage" and is dependent on your deeds.
Arizal - "First Marriage" is the first time the soul comes down into this world. Then his perfect match comes down with him and they will get married without difficulties. Once a soul is reincarnated, whether his predetermined spouse is reincarnated with him is dependent on his actions. If she is not he can marry someone else. (There are more details to this opinion)
tl;dr According to Rambam and Meiri ones spouse is not determined before one's birth. Rather the normal mechanism of reward and punishment is present. That is, if one is deserving of reward, God will arrange for that person to meet a spouse who will be more positive, if one is deserving of punishment, God may arrange for one to meet a spouse who will be more negative. Others are left to the winds of chance. According to this explanation, there is no difficulty of multiple marriages, or no marriage, for marriage is not predetermined.
Rambam writes explicitly (Sh'monah Ferakim ch. 8) that it is a mistake to think that whom one will marry is predetermined, :
אלא שהרבה יטעו בו בני אדם, ויחשבו בקצת מעשי האדם הבחיריים - שהוא מוכרח עליהם, כגון הזיווג לפלונית, או היות זה הממון בידו. וזה אינו אמת
However many err with this, and this that some free acts of man are actually out of his control, for example marriage to a particular woman, or that he will acquire particular money. This is false.
Rambam seems to be specifically identifying (at least a simple reading of) the Gemara as a mistaken view.
את דברי חז"ל הוא לא מסביר, אלא הוא יוצא נגד אותה השטה, כי הוא סובר - שלא כל מה שנאמר בעניני אגדה בעניני מחשבה, לא כל מה שנאמר בתלמוד הוא מוסכם על דעת הכל, אלא דעת אומרן בלבד... גם כאן בענין מה שחז"ל אמרו"..."ארבעים יום קודם"... "אצל הרמב"ם הדברים הללו אינם דעת חכמי ישראל...רמב"ם סובר שהדברים הללו כולם הם דברי יחיד והם דחויים
He is not explaining the words of Hazal, rather he is opposing that view, for he holds that not everything stated in aggadah in regards to philosophy--not everything in the Talmud is accepted by all. Rather, they reflect individual views...So to here regarding that which Hazal said '40 days before...' To Rambam, these words are not the view of the sages of Israel...Rambam holds that these things are individual views and are rejected.
It should be noted that in a resposum (Blau 436), Rambam ostensibly explains the Gemara as saying that a spouse isn't predetermined, but that if a person is uniquely righteous, to the point that he merits hashgach p'ratit, then due to his merits, God will arrange for him to meet a woman who is appropriate for him:
וזה שאמ' החכם בתו של פלוני לפלוני דרך שכר או דרך פורענות הוא זה. שאם זה האיש או זאת האשה עשו מצוה שראוי ליתן שכרה בהם זיווג יפה ומשובח הקדוש ברוך הוא מזווגן זה לזה. וכן אם ראוי ליפרע מהם בזיווג שיהיה בו קטטה ומלחמה תמיד מזוגן...ואין דבר זה השוה לכל אלא לאלו שנתחייבו או שזכו
This that that sage stated "the daughter of Ploni is assigned to Ploni", was stated in the context of reward and punishment. That if this man or woman did a mitzvah that deserves the reward of an appropriate match, God will match them to each other. And similarly, if they are deserving of punishment through a match in which they will frequently quarrel...And this matter is not universal, but is limited to those who merited.
Effectively, this understanding removes any novelty according to Rambam. It ends up saying nothing about predetermination, and simply gives one example of some life circumstance which (like other life circumstances) can be included in the realm of reward of and punishment.
This understanding is stated explicitly by Meiri Sotah (2a)
כשם שהוצאת האסירים ממצרים היה בהשגחה מאתו ית' כן הושבת היחידים והזווגים זה בזה הוא בהשגחה מאתו ית'...והעמידוה בזווג שני ר"ל שהוא בזמן ראוי לענש וגמול אבל בזמן שאינו ראוי לכך והוא הנקרא זווג ראשון מצד שסתמו הוא בזמן הקטנות סמוך לפרק יהיה ענינו כפי המקרה או מערכת התולדה
Just as the exodus of the captives in Egypt was with hashgacha from God, so too the arrangement of couples with each other is with hashgacha from God...Hazal referred to this as "second marriage" since the time of a second marriage is the point at which a person would be deserving of reward and punishment, but when he isn't deserving of this, which is called the first marriage, since generally the first marriage is while a person is still a minor close to maturity, his marriage will be based on coincidence or the circumstances of his birth.
R. Elchanan Wasserman (Kovetz Ma'amarim V'igros Vol. 1 p. 42) also explains Rambam as rejecting the Gemara in Sotah.
קידושין מ' ע"א א"ר אילעאי אם רואה אדם שיצרו מתגבר עליו ילך למקום שאין מכירין אותו וילבש שחורים ויתכסה שחורים ויעשה כמו שלבו חפץ ואל יחלל שם שמים בפרהסיא וברי"ף ורא"ש פרק ואלו מגלחין כתבו דליתא לדר' אילעאי דקיי"ל הכל בידי שמים חוץ מיראת שמים ונראה מדבריהם דר' אילעאי פליג ולית ליה הא דחוץ מיראת שמים ותימה גדולה לומר כן דהא יסוד כל התורה דהרשות נתונה לאדם לבחור בטוב או להפכו ככתוב ראה נתתי לפניך היום את החיים ואת הטוב ואת המות ואת הרע וגו' ובחרת בחיים ואיך אפשר שר' אילעאי יחלוק בזה וצ"ע
עכ"פ לפי דברי הרי"ף אפשר לישב דברי הרמב"ם באגרותיו שכתב אהא דאמרינן בגמ' מ' יום קודם יצירת הולד בת קול יוצאת ומכרזת בת פלוני לפלוני והרמב"ם כתב שאינו כן דנשואי אשה הן מכלל המצות והרשות נתונה לאדם לישא אשה או שלא לישא כלל ולכאו' תימה שהרמב"ם חולק על הגמ' מכח קושיא ולדברי הרי"ף יתישב דהסוגיה הנ"ל סוברת כר' אילעאי ולא קיי"ל כוותיה
Kiddushin 40a: R. Ilai says, "if a person sees that his inclination is overpowering him, let him go to a place where they don't recognize him and don black and cover in black and do whatever his heart desires and not profane the name of Heaven in public." And the Rif and the Rosh in Perek V'eilu Megalchin write that we do not follow R. Ilai because we hold that everything is in the hands of Heaven except for fear of Heaven. And it appears from their words that R. Ilai disagrees and does not hold of "except for fear Heaven" [i.e. even fear of Heaven is in the hands of Heaven]. And it is very astounding to say this, as the foundation of the entire Torah is that man is given the ability to choose the good or its opposite, as it is written: "see that I have placed before you today the life and the good and the death and the bad etc. and you should choose the life." And how is it possible for R. Ilai to dispute this? And this requires further analysis.
Nevertheless, based on the words of the Rif we can explain the words of the Rambam in his Letters, where he writes about that which the Gemara says "40 days before the formation of the embryo a heavenly voice goes out and announces 'the daughter of So-And-So for So-And-So.'" And the Rambam writes that this is not so, for marriage with a woman is included in the mitzvos and the ability is given to man to marry a woman or to not marry at all. And it seems astounding that the Rambam would dispute the Gemara on the basis of a difficulty. But based on the words of the Rif it can be explained that this sugya holds like R. Ilai [that everything is in the hands of Heaven, including fear of Heaven] while we do not hold like R. Ilai.
For more on the approaches of Geonim and Rishonim to aggadot, and when they felt comfortable disregarding them, see here.
Perhaps the Medrash is simply suggesting that a person has a certain "type" that they are attracted to. In other words, we each have different personalities, psychological and biological causes which make up whom would be our ideal mate. The Chazal is saying that there is a certain type of woman whom we are attracted to. This already in our "nature". It doesn't mean there is a particular girl for you. It just means a "type".
This would solve all the questions regarding divorce, or people who married more than one wife (like Avraham), etc.