Q: do your really good melodies come naturally to you, or do you experiment and mess around until you make a really good melody by accident
A: i think you just described the same way twice, but there is another way which is to try to make a good melody on purpose. sometimes that happens too