This topic may be understood after learning several Mishnayot Ketubbot 1, 9 and a Mishna in Baba Batra 8, 5 and Kiddushin 4, 8.
See Gemara Kidushin 74a:
אמר רב נחמן: שלשה נאמנין על הבכור, אלו הן: חיה, אביו, ואמו . &rml;
Rav Nahman said: Three are believed with respect to a first-born. These are they: The midwife, the father and the mother.
חיה - לאלתר, אמו - כל שבעה, אביו - לעולם כדתניא: (דברים כא) יכיר - יכירנו לאחרים, מכאן א"ר יהודה: נאמן אדם לומר זה בני בכור, וכשם שנאמן לומר זה בני בכור, כך נאמן לומר זה בן גרושה וזה בן חלוצה וחכמים אומרים: אינו נאמן.
The midwife, [only] immediately. The mother, the first seven days; the father, for all time As it was taught: He shall acknowledge [the firstborn]: [i.e.,] he shall acknowledge him before others. Hence Rabbi Judah said: A man is believed when he says: "This son is my first - born". And just as he is believed when he says: "This son is my firstborn", so is he believed when he says: "This is the son of a divorced woman", "this is the son of a haluzah".
But the Sages say: He is not believed.
אבא שאול היה קורא לשתוקי בדוקי. מאי בדוקי? אילימא שבודקין את אמו ואומרת לכשר נבעלתי - נאמנת, כמאן? כרבן גמליאל, תנינא חדא זימנא דתנן: היתה מעוברת, ואמרו לה מה טיבו של עובר זה? אמרה להם מאיש פלוני וכהן הוא, רבן גמליאל ור' אליעזר אומרים: נאמנת, ורבי יהושע אומר: לא מפיה אנו חיין ואמר רב יהודה אמר שמואל: הלכה כרבן גמליאל חדא להכשיר בה, וחדא להכשיר בבתה. הניחא למאן דאמר לדברי המכשיר בה פוסל בבתה, אלא למ"ד לדברי המכשיר בה מכשיר בבתה, אבא שאול מאי אתא לאשמועינן? דאבא שאול עדיפא מדרבן גמליאל, דאי מהתם, ה"א התם דרוב כשרין אצלה, אבל היכא דרוב פסולין אצלה - אימא לא, צריכא. אמר רבא: הלכה כאבא שאול.
"Abba saul used to call the shethuki 'beduki'". What is [implied by] beduki? shall we say that we examine his mother, and if she maintains, 'I cohabited with a fit person,' she is believed? Then with whom [does this agree]? with Rabban Gamaliel! but we learnt it once. For we learnt: if she [an unmarried woman] is pregnant and is asked: 'what is the nature of this child? ' and she replies, 'he is from so-and-so, who is a priest': Rabban Gamaliel and Rabbi Eliezer said: she is believed; Rabbi Joshua said: we do not live by her words. Now, Rav Judah said in Samuel's name: the halachah agrees with Rabban Gamaliel! - one is to declare her [the mother] fit; the other is to declare her daughter fit. Now, that is well on the view that he who declares her [the mother] fit, declares the daughter unfit. But on the view that he who declares her fit declares her daughter fit [too], what does Abba Saul come to teach us? - Abba Saul's [ruling] is more remarkable than Rabban Gamaliel's. for if from there, I might argue, [it is only] there, where most [men] are fit for her; but here, that most [men] are unfit for her, I might say, [she is] not [believed]. Hence it is necessary. Said Raba: the halachah agrees with Abba Saul.
See Rambam, Kedusha, Isure Bia, 18, 13-14:
Halacha 13 [The following rules apply if we] saw that an unmarried woman engaged in relations with a man who then departed. She is asked: "Who is the man with whom you engaged in relations?" If she says, "He is an acceptable man,"her word is accepted. Moreover, even if we see that she is pregnant and we ask her: "From whom did you conceive?" and she says, "From an acceptable man," her word is accepted and she is permitted [to marry] a priest.
Halacha 14 When does the above apply? When the place where she engaged in relations was on a thoroughfare or in a carriage in the fields where everyone passes by, and most of the passersby are acceptable and most of the inhabitants of the city from which these passersby departed are acceptable. [The rationale for this stringency is that] our Sages elevated the standards required with regard to lineage54 and required two majorities. If, by contrast, most of the people passing by would disqualify her, e.g., they were gentiles, mamzerim, or the like, even if most of the inhabitants of the city from which they came were acceptable, we are suspect regarding her [status]. Perhaps she engaged in relations with a person who would disqualify her. Hence, the initial and preferred option is for her not to marry a priest.56 If she marries one, she need not divorce. [This ruling also applies] if most of the inhabitants of the locale were unacceptable even though most of the passersby were acceptable.
Moreover, if they already were living in concubinage, the halacha addresses that obviously (following Chazaka) that the offspring is born from this couple. If they were already engaged and he agrees that it is his offspring, it is his offspring following the halacha.
See SA EH 4, 27:
כז אֲרוּסָה שֶׁנִּתְעַבְּרָה וְהִיא בְּבֵית אָבִיהָ, אִם הִיא אוֹמֶרֶת שֶׁמֵּהָאָרוּס נִתְעַבְּרָה, אִם הוּא מוֹדֶה אוֹ שֶׁאֵינוֹ בְּפָנֵינוּ, הַוָּלָד כָּשֵׁר. וְהָוֵי בְּנוֹ לְיוֹרְשׁוֹ. וַאֲפִלּוּ אִם הָאָרוּס אוֹמֵר שֶׁאֵינוֹ זוֹכֵר רַק שֶׁאֵינוֹ מַכְחִישָׁהּ (שָׁם בְּהָרַ''ן).
##Conclusion: The child is not Mamzer and is considered as the son/daughter of the couple.