To explain this, we first need to look at what the Rishonim [רא"ש ר"ן רשב"א ריטב"א ומאירי] wrote, that the Rif omitted the din of Rav Yosef that הגדילו יכולים למחות [the ability of a קטן to retract when he reaches age]. It could be that the Rambam and the Rif are consistent with their opinions elsewhere ["לשיטתם" in the vernacular], as we will hopefully explain [ועי' באבי עזרי, ובמה שאכתוב יבואר יותר].
The Gemara in Yevamos [45b] says:
ההוא דהוו קרו ליה בר ארמייתא אמר רב אסי מי לא טבלה לנדותה ההוא דהוו קרו ליה בר ארמאה אמר ריב"ל מי לא טבל לקריו
There was a certain man whom people would call: Son of the Aramean woman, [as they cast aspersions on the validity of his mother’s conversion. With regard to that case,] Rav Asi said: Didn’t she immerse for the sake of purifying herself from her menstruation? [A similar incident is recounted:] There was a certain man whom people would call: Son of an Aramean man, [as they cast aspersions on the validity of his father’s conversion. It is not clear if the Gemara understands that this makes the child a gentile or if the child is Jewish but his father's invalid conversion will hurt the child's shidduch chances. The Taz understood the latter way. cf. Maharsha ]. Rabbi Yehoshua ben Levi said: Didn’t he immerse for the sake of purifying himself from his seminal emission? [That intention is sufficient to consider the immersion an immersion for the sake of conversion.]
The Rif asks from the statement of R' Yochanan [Yevamos 46b] that geirus requires a court of 3 because it says "משפט" and thus a Beis Din is required [and so we pasken], yet here there was no Beis Din?! He answers that R' Yehoshua Ben Levi meant that בדיעבד we don't disqualify his son since he immersed for the sake of his seminal emission and wouldn't have done so had he not converted earlier. What R' Yochanan meant was that we don't let a person marry a Jewish woman and treat him as a full fledged Ger unless he converted in front of three.
The Ramban and the Rashba asserted that according to the Rif, geirus in front of a court of 3 is critical [מעכב] and prove this from various sources. But this only applies to קבלת המצוות whereas מילה and טבילה according to the Rif are only לכתחילה.
This is truly wondrous! It compels us to explore - What case is R' Yochanan talking about that we require 3, regarding which the Rif said that it is only לכתחילה? If he is talking about קבלת המצוות then how do we know anything about מילה and טבילה requiring 3 לכתחילה? And if he is talking about מילה and טבילה requiring 3 לכתחילה, then where do we get that קבלת המצוות requires 3 even בדיעבד??
The whole notion of לכתחילה and בדיעבד is hard to fathom here. R' Yochanan cited a pasuk to prove his din, implying that it is מדאורייתא. So how do we get from this that there is a לכתחילה and בדיעבד?? Those categories don't apply to dinei Torah? Do you know any psukim that say "do it this way לכתחילה and this way works בדיעבד?" I don't either!! So how can the pasuk of משפט only be talking about a לכתחילה case??
ודברי הרי"ף סתומים וחתומים!!