2 ways: by Rote, and by Reason
Often I have found that ‘learning by ear’ (or ‘orally’) is associated with learning traditional (or folk) music - and ‘learning by notation’ first is the classical way. In fact, the value of ‘learning by ear’ for young classical musicians was well established in the 1940s by Shinichi Suzuki.
Both classical, traditional - and indeed any type of music - can be taught orally. But, over the centuries, as classical music has evolved in complexity, particularly in polyphonic contexts with ensemble and orchestral pieces as well as multy-voiced music on one instrument, the challenge to a classical musician’s memory increases to nigh on impossibility! But, having direction from the printed page takes all the torment out of the process. I do, however, like to remind my students that every time they go to a concert to hear a truly great musician, they will not usually find the soloists working from the texts or scores – no-matter how complex the ensemble or music genre!