Discovery. Trial and error. Observation of nature.
When I was first learning the piano I numbered the notes from Beethoven's Fur Elise, then numbered the keys on my keyboard to match. Then I just pressed the keys in order. Eventually, through muscle memory, I could play the piece pretty well. But I had not learned anything. I just imitated.