The normal mechanism of monster creation, responsible for the vast majority of monsters in Nethack, is used when the game wants to create an unspecified opponent of adequate difficulty for the player. This is what the frequency field refers to in the individual monster pages. See Monster frequency for details on what can be created and extinctionism about limits to that.
Occasionally, players will encounter monsters far too difficult/weak or in the wrong dungeon branch. Usually, these opponents have not been created, at least not in their current form, but are the result of a polymorph trap. Monsters can also use potions and wands of polymorph, or be innate shapeshifters. All bets are off what a polymorph might result in.
Demons may also summon each other. A player polymorphed into a demon can do this, too ("Some hell-p has arrived.").