The last point is quite interesting since I think there are things/sounds/rhythms that naturally come from particular instruments so depending on what you use to write a song, the shape of the tune you produce will change. I know there are certain riffs or ways of playing that I like doing on the guitar and I'm sure they come across in what I write. This partly explains the For Martha piano since once you have some basic chords there are some things that feel very natural to play on the keyboard... so of course you scribble them down and there we have the beginnings of a song. Another way to look at this is to see how hard it can be to transpose something to another instrument. I do enjoy a bit of Apocalyptica and knowing how to play guitar and cello I realise how much skill you need to play metal on a cello.
When coming up with an actual melody I am, in some ways, clueless! I like to think I write some catchy tunes once in a while but where they come from I don't really know. I listen to a fair bit of music and also quite a wide range of genres (to put it stereotypically everything from Bach to System Of A Down) so maybe it's all just a mash-up of everything I've heard before, but I hope not. At least when writing a tune to already composed lyrics the words themselves tend to have a melody hidden behind them just as speaking has certain rhythms and intonations. Possibly I always need some kind of lyric in my head when writing a song even if it is fairly subconscious and that, combined with the "science" of what sounds nice together, is all there is to it. Now I just need to know where poets and lyricists get their words from!
PS If you didn't see Goldie compose a classical piece of music for the Proms on the BBC then you should - it was awesomeness... and mash-up.