Songwriters find their inspirations in many different places. Some people wake up from a dream with a snatch of melody going through their heads. Some play around with chords until they get something they like. Some get together with friends or band mates to write something together. When writing a song, the important thing isn't to follow a set procedure and do it right. What's important is to find a process that works for you.
Play around with lyrics or music. If you hear a snatch of melody in your head, for example, start singing it. See where it goes. If all you have is a few words, sit down with a pen and paper. Write whatever comes to you. If you play an instrument, sit down and play whatever comes into your head.
Write one part of it. If you can come up with a chord progression for a verse, for example, you can build on that by writing lyrics and coming up with a tune. If you can write a tune to begin with, you can easily fill in the chords later. Even if all you can think of is the words, they might inspire you with a melody later which will let you finish the song.
Record your ideas as they come. Songs often come in spurts and snatches of melody. The easiest way to record your ideas is to bring a portable recorder with you everywhere. Every time you get an idea for your song, you can sing or hum it into the recorder.
Come up with a song structure. Most songs have a verse-chorus-verse progression, but yours doesn't have to. Your song could have several different sections or just one section.
Decide on the phrasing and dynamics. Try singing and playing your song loudly and angrily, quietly and sweetly, or cheerfully and brightly. Play with the emotional feel of your song until you really know the right way to perform it.
Play and sing your song through several times until it sounds just the way you want it to. Then, record your final version. When you experiment with a lot of different ways of performing and arranging a tune, it is easy to forget which one you decide on. Even a low-fidelity recording will remind you how your song is supposed to sound.
Sometimes, you can't finish a song in just one go. If you get stuck, put it away for a few months and then come back to look at it with fresh eyes.