Actually, no one ever "learns" to compose in the way we might think.
Every composer is self-taught in the truest sense.
A few things to think about:
1. Sometimes a composition is born from "doodling," and at other times it
is an expression of an emotion into sound.
2. Unless we’re taking the basic musical material from another piece, the birth of a composition is mysterious. It often just "comes to us."
3. At some point in every composition, the music begins to sound a little stale. It begins to lose energy. See if you can identify these spots when you're composing, and introduce
something different there. It can be a subtle difference, like a slightly
different rhythm in the melody or a new harmony. Or it can be a bigger difference, like a contrasting section of music.
This third point is bigger than it may seem at first, and it’s a key to understanding much of the great music we hear by Bach, Beethoven, The Beatles, and Miles Davis, among others.
Dig deep into these ideas, as well as your own ideas about composing. The more we become interested in the process of composing, whatever that may mean to each of us, the more rewarding the experience can become.
Good luck with your music!
You may enjoy my Flowing Water ebook. Here it is: