So when writing up my old encounter tables, I always tried to have a few spellcasting enemies. I often write up monsters with the explicit descriptor of spells in their stat lines, the idea being the person running a game using this content (let's face it, everyone here is a GM/DM) will substitute their own stocking rules for it.
But after doing so, I have found that there are very poor rules and guidelines in the games at least that I have read of what exactly random NPC spellcasters should have prepared. Unless it's written directly in the encounter or monster write up as having these spells/spell-like abilities it seems to be a toss up between "the same spells a player-character should have at this level" or just winging it and letting the DM decide what spells they have prepared.
So instead, I have written up a list of 20 generic spells that are applicable to NPC magicians. These include rival magic-users to the party, bandit-wizards, orc spellcasters, witches, wizard ghosts, dark cultists, and so on. Fair warning, these spells are really generic, and are meant to be applicable to NPCs that the parties interact with in the dungeon, so they are almost all combat focused. Mostly because if the 1 HD bandit rolled Floating Disk as his starting spell on the MU starting spell table it's mostly just a waste of an encounter. This list avoids that problem totally by making all the spells immediately useful in the context of how PCs will face them; almost always through combat encounters. You could also learn these spells from these characters, offering a unique vector for character advancement.
For rules; assume each monster Magic-User has a number of prepared spells they can cast equal to their HD. If the monster's description or stat-line describes them as being extra powerful (casting as though they were a higher level) or having lots of magical trinkets and artifacts or carrying a spellbook, add extra spells. If the stat-line has them described as being a poor or primitive spell caster, reduce the number of spells but with a minimum of at least one. If you suspect the monster(s) have been fighting or distracted recently, roll a d100 percentile and let the monster MU keep that percentage of their spells. Also if the PCs have done any shenanigans recently like removing vital sources of food and water or killing a bunch of monsters belonging to a specific monster group, the enemy MUs may also have less spells because of that.
Spells are cast by the enemy magic user by speaking an incantation. Because the spell is spoken; a successful hit on the enemy during casting interrupts their spell. Spells are declared during the opponent's round, but only take effect on the start of the next opponent's round, giving the players a chance to retaliate. Intelligent enemies will position guards or try to cast from a far away position so that you can't stop them. I use team initiative and hold my player's to the same rules.
Also; this list doesn't use spell levels because they're lame and I'm tired of them. However, it is roughly ascending in power. So you could say rolls of 1 to 6 are 1st level spells, rolls of 7 to 12 are 2nd level spells, and rolls of 13 to 20 are 3rd level. For most wandering encounters, the first 20 results are the most fitting and fair, so just roll a d20 equal to the number of HD the monster has for their spells. Special named NPCs or the leaders of a Witch coven etc. may get one or two better spells. For them, you can roll 1d10+10 for a random powerful spell.
20 Enemy Spells
 Rust Spray
Sprays a disgusting red-brown fluid that rusts and corrodes metals. The caster chooses what to try and spray- if it hits a sword, the sword gets -2 to hit, if sprayed on armor, -2 AC. If the caster sprays it in your face; you are blinded for one round and get -4 to hit. You can choose to block this with your shield- wooden shields are unaffected, but metal shields will lose 1 point of AC.
This rust spray does work on magic items, but only gives a penalty of -1 AC or To-Hit instead. With a downtime turn of rest, you can clean, polish, and scrub the rust clean and repair your piece of equipment, which removes the negative and restores the item to full strength.
 Elemental Blast
Fires a bolt of elemental energy, dealing 1d6 + HD damage on a hit. This spell uses an arcane/magic to-hit roll, which is a d20 + caster's level or HD vs the target's AC, no saving throw. If the damage roll is a 6, the bolt can inflict a bonus effect.
This spell deals damage of a random element. The element is (roll 1d4) Fire, Ice, Lightning, Acid. For generic casters, this damage can be random, but for themed casters like Pyromancers, Ice Witches, etc you can just assign them the most fitting element.
Telekinesis has three possible modes of use. The caster can use any of the three, but can only use one per casting of this spell.
Shove the target back a square, or a short distance in theater of the mind. The shove knocks targets prone; requiring a round to stand up. Creatures get a save to avoid being tossed off a ledge/back into spikes and so on. If you get shoved back into somebody else that's the same size or smaller then you, you both fall over. If you get shoved into a wall, take 1d3 improvised damage.
Pull moves the target closer to the caster. Creatures in a backline will be shoved past the person in front of them and now be considered in the front line.
Throw allows the caster to toss a dagger, stone, or other random item as per a thrown attack. The weapon must hit with an unmodified d20 attack roll and deals the damage of the weapon if it hits. This spell cannot be cast on items held or weighed down in some way.
 Evil Eye
Stares at a target with evil intent. The target gets -2 against their next saving throw. This spell can also be used on unpaid retainers, lantern-boys, and untrained animals (dogs but not war dogs, etc) and will make one creature flee. Creatures who flee from fights will be very remiss to rejoin the party's exploration even if you actually manage to find them before they're eaten by something.
Significantly dims sources of light in the area- torches become as bright as candles, candles becomes as bright as matchsticks. Anyone not holding a torch experiences a negative To-Hit and can't tell what's going on. Creatures who can see in the dark aren't effected and will be more giddy to cast this spell then surface dwellers. Also I know this already a spell everyone has and uses, but I like this version better.
Target creature takes 1d4 damage to a random stat. The damage is presented as a physical injury or disease as a curse would- like a great big boil appearing on their nose for Charisma or their veins turning black and getting a bit of a cramp for Dexterity, etc. This damage is recovered at a rate of 1 point per season / in between each session.
Creates an energetic field around a target, making the next three melee attacks against them be made at disadvantage. The caster can place this on any target within sight distance. The caster can also split up the shield evenly among three different targets for one attack with disadvantage against each creature.
The caster of this spell is surrounded by a whirlwind. The whirlwind picks up dust and swirls around the caster unpredictably; causing all ranged attacks fired through the whirlwind to have disadvantage to hit. This whirlwind can be large and fierce enough to protect multiple individuals; either around the caster in a radius or a number of people = caster level for theater of the mind. This spell lasts until the caster dies or moves from where they are standing.
The caster gives off an animal howl. It echoes through the air- if the caster is part of a faction, this spell has a 1 in 6 chance to call reinforcements equal to 50% of a regular patrol size, or the rest of the patrol if they were separated beforehand. If no reinforcements exist, this spell instead has a 1 in 6 chance to draw a wandering encounter in, which will roll reaction checks and can be hostile to both the magician's party as well as the player's party. Unlike other spells, this one can be sustained over multiple rounds if nobody strikes the MU to stop it- every round rolls another chance until the spell is ended, the caster is struck, or an encounter is rolled.
This spell allows the caster to empower one being in their line of sight with supernatural strength. The target gains +1d6 temporary hit points, +1 AC, and +1 To-Hit and Damage as well as increasing in size and bulk. Goblins become as big as short men, orcs become as big as ogres, etc. This spell will end if the caster is killed. Those who have been empowered by this spell will be extremely tired after a battle, requiring a hearty meal or time to recover; and will have negative versions of this spell's effects until they can recover and sleep it off.
Additionally; this spell can be used on 1 Hit Point vermin or tiny creature like a spider, rat, gremlin, etc. and turn it into a 1 HD giant version as a monster with appropriate stats. The caster has no special control over the creature but the creature will generally attack someone if it is thrown at them as its transforming or if they were the pet of the caster's they'll defend them.
Magical curse that causes immense pain. Deals 1d6 damage and causes you to drop whatever you are holding. Shields have straps and aren't dropped, lanterns hung from the belt aren't released by your hand and therefore don't drop, etc. Save to resist the spell.
The caster flies up into the air and can fly around. This lets them avoid all melee attacks with short weapons; but reaching weapons like spears or whips can still hit if the ceiling is low enough. Ranged attacks can obviously still hit, but the caster gets +2 AC from flying around quickly. The spells ends if they touch the ground again- they can stay airborne (and pelt spells at you from above) for up to 3 rounds before their flight ends.
The caster or one target they choose turns partially invisible. All of their equipment is made invisible as well. You cannot see them or their shadow either. Hitting the creature without some kind of indication in this form is essentially impossible- assume a negative To-Hit modifier of -10 with situational reductions of this penalty due to surrounding clues like footprints, their reflection that still shows up in mirrors and pools of water, their breath in a cold room, etc.
Every time the invisible creature make a successful attack in melee against someone, or any time you successful harm them, assume that 1d10% of their body is covered in blood now- reduce the penalty to hit them by this percentage. Once the creature reaches a total of 75%+ or more they are revealed enough that their location can be accurately guessed, so no penalty is applied. Assume that throwing a bucket of paint on them or marking them with glowing dust will cover 2d30% of their body in a throw.
The caster destroys 1d4 pieces of equipment. Swords shatter, armor falls to pieces, vials burst, wooden staves turns to sawdust, etc. Magic equipment is immune to this effect. This spell can also be used on an animated entity like a golem or living armor and deal (1d4)d8 + caster HD damage. If the being is intelligent, they get a saving throw. Genuinely important, well maintained items like heirlooms or things in protective cases might just be damaged by this spell instead.
 Toxic Cloud
This spell creates a toxic cloud of a random color. The cloud can be lighter then air (goes up) or heavier then air (goes down) at the behest of the spell caster. The cloud fills in space but is easily blown away by the wind or other wind related spells or blasts.
The toxic cloud deals 2d6 damage for every round you breathe it in. Having a facemask or covering your mouth with a bit of cloth reduces this to 1d6 damage. Characters may be able to hold their breath to run through the cloud quick enough to get out- but only characters with +2 Constitution or better can succeed at this without breathing. This spell produces enough toxic fumes to fill a large room or battlefield trench, and will slowly dissipate over the course of 3 exploration turns. The caster has no special immunity or resistance against this spell.
 Magic Chains
Conjures manacles and ankle-weights on a target's body, and magically connects chains from these into the nearest walls or solid objects. The creature can still attack, block, and cast spells normally but cannot move. The only way to free yourself is to be supernaturally strong to pull the chains out of the wall (+3 Strength or better), break the chains with a +2 Magic Weapon or better, or concentrate for a round to will the chains to disappear- giving you a save vs magic to dispel the chains. You cannot attack or take any other actions during your concentration round.
In addition; even after being freed from the chains you are stuck with the manacles and ankle weights. These increases the target's encumbrance by one unit or step, so an
unencumbered character becomes lightly encumbered, encumbered characters
become heavily encumbered, etc. If you use weight-based encumbrance,
then consider 50% of their maximum weight taken up by this spell. They can be broken off with metal working tools over a turn of downtime- however this makes a tremendous noise and has a 1 in 6 chance to attract a wandering encounter.
This spell conjures forth a creature of equal HD to the caster. The creature is chosen by the caster when the spell is cast, and requires total concentration. The spell takes 3 rounds. The first round begins the casting and opens the portal, the second round draws the monster through the portal, and the third round binds the monster to the caster's will. If the caster is hit...
During the first round- The portal isn't opened and the spell is wasted.
During the second round- The spell fails, but the portal is opened and energies swirl. Roll a spell cataclysm or for a random demon to come through the portal.
During the third round- The monster is summoned but the caster loses control of it- causing it to attack wildly or run away if its a fearful thing.
If the spell is successful, the monster serves the caster's side faithfully and attacks. It has no morale or never flees from combat. The monster naturally breaks apart and disappears after one day.
 Elemental Spear
Very similar to Elemental Blast above, except this version is more powerful. The caster raises their hand and throws a spear of elemental energy. The spear requires a d20 + HD of caster roll to connect, and deals 2d8+HD of a random element in damage. If one or both die get a 6 or higher, the target suffers the Overcharge effects. To determine the element, pick the most fitting for the NPC or roll on the random table. (Roll 1d4) Fire, Ice, Lightning, Acid.
In addition; whatever element the spear is also grants it an extra effect on hit.
Fire- Creates a cloud of ash and smoke, choking anyone adjacent to the target who tries to cast a spell. If the spear is blocked by the target has a wooden shield, the shield burns up.
Ice- All potions carried by target freeze. You can't drink them; requires a turn to thaw.
Lightning- Knocks you to the ground, requiring a round to stand up. This is in addition to getting stunned from the electric shocks- meaning you may fall to the ground and have to wait to even get back up again from the convulsions.
Acid- Splashes acid around you- dealing 1d6 damage to everyone standing adjacent to you. If you're in a tight hallway this could be the whole party.
 Reflect Spell
This spell can be cast as a reaction, but only if the caster has not cast a spell in the last turn. The caster will stretch out their arms and create a silvery screen that bounces magical energies or blasts back at the sender. Spells will return at roughly the same level of power, angle, and intention as the original spell, simply reversed. So a spell in the form of a cone is sucked up and spit back out in the same cone shape, where as a spell that targets an individual will bounce back to the original spellcaster, etc.
caster of the first spell (the spell that is being reflected) may make a
save vs magic to cancel their spell out before its effect bounces back
to them- if you succeed on your save, you lose your own spell but you
didn't suffer its effects. If you fail, proceed as though your own spell
just hit you. If this spell was used to reflect a magic blast instead, then no save is granted and the countering-caster rolls a magical attack roll +2 to see if they hit you with the reflected blast.
This spell gives the target a feeling of dread. Their mind is filled with torturous images, feelings of hopelessness, and damages their very will to live. The target of this spell loses 50% of their current hit points. Save to resist the spell.