This is something that varies GM to GM. I write pretty complicated stories with a couple of backup plans, because I don't feel like I'm especially quick on my feet. My partner has a 3 x 5 with bullet points and just sort of makes up details on the spot.
One piece of advice that will probably come to you a lot as you get more GMing under your belt is to keep a notebook. You are going to have to make up NPCs and locations on the fly, and it can be hard to remember that blacksmiths name you pulled out three sessions ago.
Plan loosely, be comfortable spontaneously adding things, and keep notes.
If you're not sure what kind of story to create, have the PC's give you a four or five sentence backstory and build it out of that. The characters will start on day 1 with motivations and they'll appreciate their ideas being used. Also, don't be afraid to bounce back suggestions to change a PC's backstory a little to help it fit with the rest of the players. Just make sure you don't change the overall concept of what their doing.