[MENTION=6775031]Saelorn[/MENTION] - what is the in game logic that prevents bombing 1st level PCs with adult dragons?
That is the extreme example.
The more common example, one so common that we take it for granted even when it is staring us in the face, is the typical structure of a long written adventure.
At the macro level, there are usually areas that are supposed to be fought in a specific order. Area 1, then Area 2, then Area 3, etc. If the players, via keen insight, realizes where to find the BBEG in Area 5 while finishing up Area 1, 99 times out of 100 they will be severely punished for honoring the in game logic that the PCs are brave and may want to stop the death of innocents sooner rather than later. (Because the PCs were supposed to level up twice and gain magic items and be "barely ripe enough" to confront the BBEG, once stripped of minions. At the right time, and no sooner.)
At the micro level, so called dungeon levels are internally "silo'd" to a bizarre degree. The PCs having defeated both Bad Guy A and Bad Guy B, Bad Guy D opts to not lift a finger to help Bad Guy C (who is getting carved up literally 110 feet down the hall), even though it completely obvious who is next on the list. Yes, we can handwave cheesy mustache-twirling excuses why the villains work so badly together, but, if we actually apply in game reasoning, it is gobsmacking how the villains behave in a very specific predictable way, instead of one of the many other equally logical options.
The reason adventures are written this way is simple: it is more fun for the players to fight more stuff, and the way to increase the amount of fun stuff to fight is to force the combats to happen in bite-sized encounters, by crippling the strategic thinking of the NPCs/monsters at both the macro and micro level. Pure metagame reasons.
Yes, it is possible to write adventures that do not feature only barely hidden rails forged of metagaming reasoning. That is, however, not the actual experience of the vast majority of D&D adventures.