It was pretty much the norm for any unmarried pregnant woman to be summoned before the Kirk Session and interrogated about the identity of the father. This was, as far as I can tell, for two reasons.
The ostensible reason was an attempt to stamp out fornication, which was regarded as a major sin (some Kirk Session records even describe it as a 'crime'). The couple were subjected to various punishments including having to appear in church as penitents, being denied the benefits of church membership, and paying a fine. Judging from the amount of time and the number of pages in the minutes devoted to records of 'discipline' by the Kirk Sessions, it was pretty ineffective.
The benefits of church membership included baptism of the resulting child, and I've come across a few references in the parish register to a child being presented for baptism by someone other than the usual parent because the usual parent is still 'under scandal'.
Digression - My own great-great-grandfather's elder sister was "presented by the mother the father being under scandal". The Kirk Session minutes reveal the nature of the 'scandal': "it having been reported to the Session by the Elders that [my great-great-great-grandfather] seldom or ever attended any place of public worship and that he had continued for several years past habitually in the neglect of this duty, the Session therefore were of opinion that he had no right to the sealing ordinances of the Gospel whilst he continued in this criminal neglect of attending the public worship of God in the Church upon the Lord's Day - they therefore did and hereby do suspend him from all sealing ordinances of the Gospell untill he give evidence of his repentance and reformation". This dire, dreadful and singularly pointless sentence evidently, and not surprisingly, had no effect whatsoever on my gggf because from then on all his children, including my ggf, were presented for baptism by my gggm.)
The other reason, not usually explicitly stated in the KS minutes, was to prevent the child becoming a charge on the parish, or at least so that they knew whom to target to pay for the maintenance of the child if the mother and her family were unable to do so.
Generally speaking the whole parish usually knew who had fathered which illegitimate child, and it was the norm for such children to be known by their fathers' surnames.
If the parents married after the birth of a child, the marriage legitimated the child retrospectively provided that the parents were free to marry at the time of its conception. So a child born in adultery as opposed to simple fornication could not be legitimated by the subsequent marriage of its parents once the one who was married at the time of conception had become free to marry.