It's a chicken-and-egg situation. Which comes first ... The lyrics or the music?
I don't know what most songwriters do, but Gilbert and Sullivan, at least sometimes, wrote the songs first (Gilbert) and the music later (Sullivan).
If you have a musical imagination it could go either way. If you have a tune belting around inside your head then it's just a matter of finding the right words for it. Or, you could copy Sullivan's method and see what tunes the words bring to mind.
I'm not quite sure your question was asking but if that's no help maybe you could explain.