You're probably going get some great advice from folks that are better DMs than me. I'll just say this; the players do something unplanned or unexpected in every session I have ever ran. I try to focus on the logical consequences of their actions and let the dice sort things out.
Yeah, creating
situations is preferable to creating
plots, because players are insane.
Even if you put 2+2 in front of them, you will have groups that will decide the answer is "banana."
If you don't have everything strung together in a "this happens and then this happens and then this happens" sequence, players can't "screw things up," because there are no predetermined things you want to happen.
So, for instance, if evil riders come into town, you might expect the player characters to fight back against them in some fashion. But some are going to want to run away and find a less-scary adventure elsewhere while others will want to join up with the evil riders. So don't have those evil riders be the planned prologue to something more -- they are the event, and you should know at least a little about them about what they want, in case the players decide to join up. And if the players want to run away, have at least a loose understanding of what's around the town so you can bring it in when necessary.
To sum up: All D&D games, whether we intend them to be or not, are sandboxes, because players are insane.