The theory is that it was told to Adam during his talks with God. Forget the fact that everyone after Adam and Eve's children could not speak or write for millions of years, except in cave drawings, and when they could, God forced people to speak other languages, for building a skyscraper.