Princess Charlotte of Monaco, for instance, was born to parents who were unmarried (and never married even after her birth). She was legitimized only through adoption, since Monegasque law at the time allowed a prince without heirs to adopt one -- and in fact, the said heir did not have to be his own biological child. Indeed, there is no way to establish biological paternity with absolute certainty under any circumstance -- even marriage. At most, marriage provides a basis for LEGAL paternity.
As it was, this did not apply to Princess Charlotte: her case was probably exceptional, because marriage is normally a requisite condition for legitimization. In any case, under Monegasque law she became legitimate: as such, official genealogies list Prince Louis II of Monaco as her legal father.
But what of the children sired by British kings through their mistresses, whom they never married, and who had no other means of legitimizing them? I'm thinking specifically of the likes of Charles II (the so-called "Merry Monarch") and William IV. The latter is regularly listed in official genealogies, among the ancestors of His Grace David Carnegie (the 4th Duke of Fife) and his namesake, former prime minister David Cameron (the two are third cousins).
Is it that King William IV openly acknowledged the children born to his mistress, the actress Dorothy Bland (called "Mrs. Jordan")? I believe that after coming to the British throne, he conferred peerages upon some of the sons, as well as the courtesy title of Lady upon the daughters.
Otherwise, if the children were unacknowledged, then historians would have no way of knowing that they likely were biologically his -- never mind the fact that they could never be legally his (I believe that his mistress died in 1816, and that he and she were already estranged by then).
There have, in fact, been numerous cases of unacknowledged bastard children, both royal and commoner. In that case, it is largely a matter of speculation and conjecture when it comes to paternal identity -- based mostly on circumstantial evidence. In the case of the Duke of Clarence (his title before becoming king), I believe that the public at large knew him to be the likely biological father of the children born to the actress, even at the time.
But even so, unless there is a public word or gesture on the part of the man, there might likely be only a question mark or blank on paternal identity. I see that King William IV is indeed listed in official genealogies as the father of (among others) Lady Elizabeth FitzClarence (from whom both Cameron and the present duke of Fife descend).
How do genealogists establish paternity in such tricky situations whereby illegitimate children are involved? Had not Prince Louis II adopted Charlotte, and she nonetheless married and had children, the said children would not have been dynasts in Monaco. But beyond that, I'm not sure if genealogists would even be able to list him as her father ...