How do you get ideas when composing music?
Have you ever heard of Bloom's Taxonomy? This is an educational theory (often accompanied by a visual diagram or model) which describes the learning process and its stages of development. It all begins with remembering, progressing through more complex stages of analysis and understanding, and ending with that step you seem to be seeking—creativity! When we learn a new skill, especially in the arts, we best learn by interacting with work others have created before us.
I recommend listening to lots of music to get inspired. Pay attention to the different parts of the music—the notes, the chords, the arpeggios, the instruments, the vocalizations. Try to identify as many separate pieces in a work of music as you can and how they interact with one another to create the whole. Listening to music might also help you to get an idea of what kind of music you'd like to create. You might try listening to some music you really don't like or that is very different from what you are used to—what makes this piece of music unpleasant or different?
If you play an instrument, a good way to gain a deeper understanding of any work of music is to try to play it. Take this opportunity to familiarize yourself with both the parts and the whole of a work of music and compare it to another.
After some listening and analyzing, you're ready to do a little tinkering! If you play an instrument, sit down with it and have some staff paper ready. (If you sing, no need to grab an instrument, but you might still wish to make notes on staff paper.) Now, start making sounds! They don't have to be good ones; just make some noise! Try to recall what you liked about works of music you've heard and try to replicate that or create a similar sound. If you would feel more "natural" playing along with other instruments, check YouTube for some simple drum, piano, or guitar music to experiment with. You might also find it helpful to record your experimentation session through a video or sound recording program. Reviewing your experimentation session can help you hear what you liked and what you'd like to make changes to, and offer you some distance that being "in the moment" does not.