You can't always predict what your players are going to do. Maybe something that seems like an obvious adventure hook doesn't take, or the party gets side-tracked on their quest. So then, as the GM, what do you do? You can't really say, "Well, the world outside of this linear path the adventure's set up in doesn't exist" as it ruins what the DMG calls "the suspension of disbelief." Instead, grab an index card, and write down six or eight encounters of the appropriate CR for the party-- the Monster Manual has listings by CR in the back. Then, when you need something on the fly, you've got it right there-- there's no surprise dragon like you sometimes get on random encounter tables, but you've still got something that's both appropriate to the party and the location, and seamlessly fits into "winging it." The DMG also has a percentile table for random adventure hooks, and if your party wanders off somewhere, just pick one that seems reasonable to have them stumble over. That helps keep the game moving fluidly, and eliminates a bit of prep for you, as well.
When I've more or less winged it, I've had a very vague idea of what's going on in the area in my mind, what kind of foes the party can expect, and what a few possible outcomes of PC actions are. Then, I just sort of react to how the players do things, if I were the big boss in charge of the tribe of orcs/gnolls/bandits/whoever your main opposition is. It lets you play a bit, too, since it puts you in a spot where you're making decisions that influence the story more broadly than "in this room, there's..."