This is a problem that I've had to deal with many times. A lot of the time, I've made up songs and then realized they were too similar to an already existing piece. About a year ago, I woke up with a beautiful melody in my head. Since I was half asleep, I wasn't fully thinking. So I figured it out on the piano and went about my day. Once I came back to it, I was very disappointed. It was "Goodbye Yellow Brick Road," by Elton John. This just goes to show that if you re-visit your songs in a different frame of mind, you're most likely to notice more.
Now although plagiarism is illegal, you can still create your own music using the foundations of existing songs. If there's a song you really like, you can figure out the chord progressions. The chords are the structure behind the melody that give music it's special feeling. If you like the way a song sounds, you can figure out the chords that were used in the song. You can then play around with these chords and try to construct a new melody on top of them. You have to be careful though, because it still has to be different from the original. Listening to music is very important, because you learn a lot from it. You can be inspired by different songs. Often, what you listen to determines what kind of musical style you have in your own playing. Believe it or not, your playing is strongly influenced by what you listen to. I believe that every piece of music is inspired by something, even if we don't' realize it.
Some artists that I listen to are The Beatles, Queen, The Rolling Stones, The Who, Elvis Presley, Jerry Lee Lewis, Wings, and other classic rock artists. Classic rock is my main kind of music I'd say. But I do enjoy other things too. I enjoy jazz, electronic, disco, orchestral, pop, and show tunes as well. I see many elements of all this music come into my own work. Songwriting is a skill, and you can only get better at it.