Classical composers were very prolific, since many (though not Handel or Verdi) were required to write music to order. Bach, for instance, wrote quickly (and often repurposed his own melodies) because he had to create new music for church services or on demand from his noble employers. Other times composers wrote quickly because they needed the money and didn't have regular positions such as Bach did.
Handel, who was a well known composer in England, was accused at the time of being hasty and careless in writing the music for Messiah, which took only 24 days.
I'm not sure about Rigoletto's timeline, but Verdi (also a well-known and respected composer at the time) and his librettist took months arguing over the libretto and negotiating with censors over its content. The music was completed a month before the scheduled premiere date.
Sometimes, like when you're a Mozart, you're so full of melody you can't contain it. But when you earn your living doing a thing, you either get good at it or starve.