Some devs already have their story laid out, others don't.
For instance, Notty has Heavy's Five's story already worked out it's just a case of putting it together. Same for other devs I know.
Some make it up as they go along.
Other have a general idea how they want things to go and build up as best they can.
A few put patreon polls up asking their players to think up content for them and those are like clusters of nonsense held together by chewing gum and duct tape.