Latin and Greek are classical, 'dead' languages.

Latin/Greek were considered part of the core curriculum for a well-rounded classical education in the upper-class for hundreds of years (some degree of retained proficiency wasn't unusual in graduates of the elite schools in Britain even through the mid 20th century). Not spoken as a primary language, sure, but far from "dead" in education.

Latin was required for philosophy, law, rhetoric, and the classics. Greek skewing more towards the sciences, logic and also philosophy. One would be constantly encounter Latin/Greek in their materials and not just as a obtuse code to memorize like how a modern biology student typically views e.g. binomial nomenclature today.

So when viewed through the 21st century lens of English dominance throughout education, it loses the context that makes it much more understandable why and how a young student, especially a precocious one, would pick up those languages specifically in the course of their tutoring, reading, etc. (And not as some kind of genius parlor trick as modern retellings tend to portray it).

Latin was the common lingua franca for scholarship even into the 18th century so studying the classical languages was genuinely useful, not just a parlor trick. It's the equivalent of a modern child prodigy in a non-English speaking country learning English as a young age to access present-day research.

In the time of J.S.M. they were languages used by academics and upper classes regularly enough that in his circles he and many of his peers had early exposure.

Hence that scene in Monty Python's Life of Brian.

Still fun today: https://www.youtube.com/watch?v=Mip30YF1iuo

That there are no native speakers doesn't mean there are no tutors that speak it.

Learning by immersion is still a very different process from learning by being tutored. One is something that young childrens' brains do almost entirely subconsciously, the other is conscious academic work.