You can’t
If you’re playing to beat the players, you will. It’s not possible to be actually fair when the referee is playing for one of the teams. Even if you’re trying to be fair, it just takes a slight bias to bend decisions in your favour in small ways that add up. And we’re all human and biased.
You're probably thinking of a different style of game anyway
There’s a old-school way of running games, and how you wrote your question contains references to it. It occurred to me that you might be confusing old-school deadly D&D with Killer GMs.
Killer GMs aren’t fun. For some rare, really motivated players the challenge can be appealing for a bit, but the GM will always win eventually and it’s only a question of how long you can survive, and how much you can mess up the GM’s plans on the way to the grave.
Few GMs actually ever ran those kinds of games except through inexperience with GMing, or as a way to get back at frustrating players (not a good situation). It’s the rare Killer GM that was skilled, did it on purpose, and wasn’t just lashing out. Even those were only fun for those rare players who liked that kind of challenge.
The style of GMing that was deadly but not Killer GM was much more demanding of the GM, but more fulfilling. The point of this style of game is to be as impartial as possible, neither out to kill the PCs nor trying to help them.
When you say
… they will be expected to think of looking for traps or listening to the door themselves rather than with me saying "Maybe you should listen to the door first?"
… you’re echoing this style of play, not the Killer GM style.
To do this style well, you have to be fair running the game, but not fair setting it up. You design deadly places to explore but ensure that it has many ways and directions to approach it, including ways to go around or escape from problems. But when you run the adventure you’re fair, neither giving them the answers or success without effort on their part, nor withholding information or success that they’ve earned through careful and thoughtful strategies.
When your players succeed, it’s real accomplishment: you just ran the impartial, deadly, but rewarding environment, and it was their own skill, own strategies, own luck, and own skill judging their chances that got them through it, not the hand of the all-powerful GM deciding who lives and who dies. It’s a very satisfying way to play, for those who are interested in it.
There is more to this style than can be put in one post. I hope I’ve prevented a disaster that you weren’t bargaining for, and piqued your curiosity enough to go learn more. This style isn’t quite the same as sandbox play, but it shares all the same DMing principles — you could do worse than studying how to run sandboxes.