Managing "Final Destination" (death) mandates by the game

I've been playing a lot of nethack lately, and I'm still a beginner, but I've noticed that when you put yourself in a disadvantage, the game sees this and IT decides that you are going to die. Perhaps you are hungry - suddenly, monsters! Perhaps you are trying to stash items / clean levels or otherwise hauling something heavy - suddenly, an army! Or, maybe the game's just had enough of you and you open a door and there are two angry unicorns, a giant, and an angry djinn that just appeared out of nowhere and for no reason as a low-level character.
I know there is a lot written about what to do when you find yourself in a pickle, and I know that there are written Bad Ideas. But I just wanted to hear about this kind of situation. What exactly is going on?
I'm not a micromanager and I find it difficult to eat the exact turn my character becomes hungry, cure diseases exactly when they come on, etc, etc. And I know this is a hard game, but it seems as if whenever you find yourself in a bad spot, the game knows this and spawns monsters/situations that make things horribly, horribly worse. Is this some mechanic of in-game Luck, maybe?
Best Answer
As well as @murgatroid99's excellent answer, when your character is encumbered, it takes up more turns to move. The game does not slow down its spawning simply because the character has slowed. So to the player, it appears that monsters may be spawning at an alarmingly fast rate.
Don't level up unnecessarily. With every level you gain the game will throw harder monsters at you. No, this is not fair. Your equipment (AC and so on) must improve in parallel, matching your level, otherwise your opponents will eventually overwhelm you. Level up slowly by letting your pet do much of the work. Kill primarily when threatened or hungry. [Why do I keep dying?]
I cannot speak for everyone but leveling up without good gear was one of my constant and biggest pitfalls, and the reason why monsters so far beyond my capabilities were being generated.
Pictures about "Managing "Final Destination" (death) mandates by the game"



Conference 2021 Opening Session: A new or obsolete Pact?
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Alesia Kozik, Brett Jordan, Brett Jordan, Brett Jordan