When she is married to another with a get that is invalid according to the Torah, she requires a get also from the second husband by rabbinic decree, so that they should not say a married woman leaves without a get. And she requires a get from the first to permit her to the world, and she is forbidden to both of them forever. Even if she married inadvertently, such as if she did not know that the get was void, nevertheless, it is so that they should not say that this one took back his divorcee after she married another (the Rambam). And to the second she is forbidden because the sages penalized them since they committed a great prohibition (Mishneh LaMelech). And if one of the two of them transgressed and brought her in, they remove her from him and compel that he divorce her. And all the thirteen ways that we learned in the Mishnah in the chapter HaZorek (Gittin 80a), and which we explained in detail in siman 17, section 257, apply to them. Only regarding the matter of inheritance, some say that her first husband inherits her, for behold, he did not commit a prohibition, as I wrote in siman 17, see there.
However, if she only became betrothed to another and had not yet entered the chuppah with him, she is permitted to her first husband and does not require a get from the second, since there was not yet a prohibition between them. And some say that even if she became betrothed, she requires a get from the second and is forbidden to both of them (the Ra'avad there). And it appears to me that his reasoning is that it is not similar to where they told her her husband died and she became betrothed, where she is permitted to the first, for there everyone sees that they testified falsely; but with a get, not everyone knows that the get is void, and they will say that he took back his divorcee after she was betrothed to another. And according to the Rambam, one could say that regarding kiddushin there is no decree, for they will more likely attribute it to saying there was a condition in the kiddushin of the second which was not fulfilled, but regarding marriage there is no condition. And in truth, therefore some say that the reason she is forbidden to the first is not because of a decree but because of a penalty, just as with the second; therefore, regarding kiddushin where there is no prohibition, the sages did not penalize them (see the Mishneh LaMelech there, and delve into this).
כשנשאת לאחר בגט הפסול מן התורה צריכה גט גם מבעל השני מדרבנן כדי שלא יאמרו א"א יוצאה בלא גט וצריכה גט מן הראשון להתירה לעלמא ונאסרה על שניהם לעולם אע"פ שנשאת בשוגג כגון שלא ידעה שהגט בטל מ"מ כדי שלא יאמרו שזה החזיר גרושתו אחר שנשאת לאחר (רמב"ם) ולהשני אסורה דקנסום רבנן מפני שעשו איסור גדול (מל"מ) ואם אחד משניהם עבר והכניסה מוציאין אותה ממנו וכופין שיגרשה וכל הי"ג דרכים ששנינו במשנה דפ' הזורק (גיטין פ'.) ובארנום בפרטיות בסי' י"ז סעיף רנ"ז נוהג בם ורק לעניין ירושה י"א שבעלה הראשון יורשה שהרי הוא לא עשה איסור וכמ"ש בסי' י"ז ע"ש אבל אם רק נתקדשה לאחר ולא נכנסה עמו עדיין לחופה מותרת לבעלה הראשון וא"צ גט מהשני כיון שעדיין לא היתה איסור ביניהם וי"א דגם בנתקדשה צריכה גט מהשני ואסורה לשניהם (ראב"ד שם) ונ"ל שטעמו דלא דמי לאמרו לה מת בעלה ונתקדשה שמותרת להראשון דבשם הכל רואין שהעידו שקר אבל בגט לאו כ"ע ידעי שהגט בטל ויאמרו שהחזיר גרושתו אחר שנתקדשה לאחר ולהרמב"ם י"ל דבקדושין ליכא גזירה שיותר יתלו לומר שהיה תנאי בקדושי שני ולא נתקיים אבל בנשואין ליכא תנאי ובאמת דלכן י"א דהטעם דאסורה להראשון אינו משום גזירה אלא משום קנס כמו להשני ולכן בקדושין דליכא איסורא לא קנסום רבנן (עמל"מ שם ודו"ק):