I have frequently seen Storytellers make what I consider to be a mistake, specifically that if it happens off screen anything can happen. Established powerful characters can be beaten by established weak characters, master locks can be picked by novice thieves and son on. This leads to a feeling of an arbitrary universe and a sense of helplessness as the pcs can't be everywhere at once and know that where they aren't any accomplishments they have made can be taken away. We saved that village and then the dm decided fuck that and destroyed it once we were gone.
A common reason for this is to fuel story, but with just a little forethought the story is even better if the universe isn't arbitrary. It is fine to undo a players actions offscreen, but have it make sense and mean something. If a well fortified town is destroyed the pcs should likely be afraid of anything that can do that. If a goblin horde destroys Waterdeep playes can't take the game as seriously. If a legitimate enemy managed to do the same thing it should raise a lot of questions, but as the mystery is unraveled it will be much better than an arbitrary dm's whims.
The other common reason for this is antagonism. If this is the case I'm afraid there's next to no worthwhile advice I can give other than don't play with an antagonistic dm and don't be an antagonistic dm. No good can come of it, the dm can always win and it shouldn't inflate his ego that as the literal master of a universe he can squash some ants in said universe.
When the world makes sense players will make plans that involve npcs as established facts can be counted on. In real life we make our choices based on who we can trust and our predictions for how things will work out. If it was a known fact that places you can't see follow strange and unknowable laws we wouldn't trust anything we weren't currently watching, and just like us neither will the pcs. By making the world and characters in it consistent you open the door to politics, large scale battles, and the idea that the players are in a real world.