That said, it is always a great idea to have the players agree with the GM what the game will be about.
When it's made clear in advance, it will probably not happen often that the players start doing things that are completely conflicting with what you have planned. And when it still happens, you can just say that you didn't think of that possibilty at all and you're currently not able to come up with a good way to handle it, so you are asking them to not follow that plan, even though it's a good idea. That's much better than to handle it simply but having everything they come up with fail until they do what you expected them to do, even though the outcome is the same. Just say I don't know or Sorry, I don't have anything prepared for this, and usually the players say okay and are willing to go with what you've planned.