This entirely depends on the artist. Some artists essentially write poems first and then work the music around them. The song Under The Bridge by Red Hot Chilli Peppers started this way. However, in my experience, it is more common for the music to be written first, including for myself.