Mozart wrote his first composition at 5. Chopin wrote his first at 7. While both are widely known as musical prodigies, most children are able to start experimenting with composing at a young age. They (most likely) won't produce sonatas and fugues worthy of publishing, but they can learn the basics of creating melodies and reap all the benefits that come from exploring music and composition.
At it's most basic level, melodies are created by using different pitch & duration. The pitch is how high or low the notes are. The duration is how long each of them are held.
Tada, a melody is born! Put in some lyrics, or words, and it's a song!
Of course, from here we can add as many complicated factors as we want until we get huge confusing works. Words like harmony, modes, or recapitulation can be used (which you can learn about if you start lessons).
But at it's core, composing is simpler than you think.