Depending on witch instrument you play, Most common being Guitar or Piano. I'm not saying my way is the right way but I normally sit with the guitar strumming chords and huming vocal melodies and sometimes nothing happens but then theres a moment were I play and sing something and it feels like it was meant to be, like it just fell from the sky. I then take that idea witch is like the spark or the flame and build it from there. It might be easy to write a song from there or sometimes it needs work to find other musical parts but thats songwriting sometimes its easy sometimes its not. Structure the song in to some kind of format e.g Intro, verse, chorus, verse, mid 8, chorus, outro, witch ever works best with the song. The more music you listen to and the more you write songs the better ear you get for it.