How does one go about composing? An idea just pops into your head or....?
Hmmm...
Ok, there's different ways to start working on a work. And different reasons in reality.
ReasonsA1. The get paid reason. Simple as that, regardless of genre someone is paying you to compose
something. You sell out your soul (ok, not really), and simply do it.
A2. The teacher asked me. Simple as that again. You should also learn something by composing the work your tutor has asked...
A3. My heart/mind/soul/nature/gawd gave me a tune. Simple as that. You, personally, WANT to compose a particular work. For whatever reason. Freedom of choice.
I find that a combination of A1 and A3 work quite nicely usually!

Not very easy to do, but still..
WaysB1. The sit on the piano bench and start playing way. Perfectly fine. You play until something clicks and comes up. You pick it up from there and develop it. If you have the theoritical chops you do so in paper ( + piano). If not you just sit on the piano until the next segment comes in mind.
B2. You sit in front of the computer and start adding loops. Perfectly fine as well. You get semi-ready loops, drums, bass and the rest and patch them up to sound nice. Very valid in some styles of music and perfectly alright even for Brian Eno.
B3. You find the external idea to kick you started. More difficult to do usually, it involves finding ways to use 'meta-art' knowledge and transfer values from somewhere into music. Perhaps it was an art painting you saw. Or a political movement. Or maybe it is the way the stars move. Whatever the reason you are pushed into composing by that, make your notes, your drafts, your symbols and your signs and then go further.
B3 v0,5. You develop a new system. Not twelve tone, not tonal, not quartal harmony, nothing. A new one. And toy with that.
I actually use all of the above, depending on circumstances. For computer games, I don't develop new pitch systems, but for academic work I did.
One of the most important factors, for an adult is the "who" is asking me to do it. Even if it feels selling out, it usually defines the style, the orchestral force, and the medium. A chamber orchestra will give you the exact forces, and normally you should also know what they tend to play: You can't go to the medieval orchestra of Shire (sayin' now) and give them aleatoric music. Or the opposite: Don't try the Boulez ensemble for some super tonal, Mozart style music.
For me, inspiration is the flick of the flame to get things started, the rest is hard work, knowledge, experience, etc...