In lots of GM forums I've seen similar thoughts: how do I stop my players from bypassing X encounter/problem/thing?
It's not a question I like, but before I didn't really have the words for it. Now I think I have found the two reasons I dislike it.
1) From the GM perspective this speaks to too much investment in the thing you don't want avoided. It's ok to like your ideas and encounters. It's less ok to be so invested in them that you feel the need to force your players to run into them and deal with them. At best it's "I want them to face this cool thing" but at worst it's "I want to show how smart/clever I am!" and that is not ok.
2) From the player perspective, forcing encounters is killing their creative ideas. The game works when the GM presents the situation, the players give what their characters do to deal with said situation, and the GM then says what happens. This falls apart if the GM is cheating to make the PCs idea less effective than it should be.
Two is the bigger problem in my opinion. Being invested in something is fine. Killing creativity however will ruin your game.
Deny creative solutions once and whatever. Twice? Three times? now you have a pattern. Eventually your players will stop trying to be creative because they know it won't do anything. Now you've killed engagement in your game, and engagement is directly proportional to fun.
This doesn't mean you can't have character options restricted. If someone set up the trap, it is possible they put in means of dealing with ways around it. But those being in place before the encounter begins and coming up only after a player tries to do something are very different things. The chief difference being a player can discover something in place before the encounter begins.
So be careful when saying a player's plan doesn't work. Let them enjoy their creativity. Let them have their moment. It doesn't mean the encounter was wasted. It just means your player found a cool way around it. And they'll remember that.