Sounf like you've had mediocre DMs. All you have to do to screw up a mage is make the encounters unpredictable enough he never knows what to plan for. If the mage always knows what's coming if course he's going to be the best. A known combat where all his memorized spells are useful is where he shines. But when you don't know what you need the wizard is not so powerful. It's pretty normal in our games for clerics and wizards to not have the perfect spell memorized because they guessed wrong.
This is a balancing point for casters that many forget. A wizard, cleric, bard, sorcerer, and warlock doesn't have access to a monster's statblocks. They don't know which saves to target, which conditions are effective, what damage types are resistant or immune, which enemies can cast spells, etc. It's all spending alot of mid-high level spell slots on uncertainties.
There's alot of metagaming that becomes apparent in these forums. I've seen complaints about the Tarrasque because they can be kited using a fly spell. Here's my question: how do you know the Tarrasque doesn't have a ranged attack when you fight it? You're gambling an attack from the Tarrasque plus the fall damage for losing concentration if you are wrong. How do you know it's range? How do you know that it even is a Tarrasque?
These answers may seem obvious because "the monster's so iconic" and "it's been discussed online." But what's online is
not what's in the PHB, the only book a player should be reading extensively.
In reality, a player would ideally never see a single statblock other than their own and their party members. Even with summons and companions, there's nothing saying that you get to look at the sheet. Which makes informed decisions much harder with them.
Another thing is how a DM is free to play entirely close to their chest. Not only are they allowed to roll behind the screen and not announce legendary resistances, they aren't obligated to tell them how they work, either. The DM doesn't have to disclose
any metagame information and the players should not even
have that knowledge in the first place. You're not obligated to know a monster's AC, To-hit, save proficiencies, features, or actions. The DM describes the creature and you must use context clues to act.
This is why playing casters is much trickier than the community lets on. A player isn't going to immediately know why a 5th-level spell that costs concentration just to give an enemy full cover is going to give the DM a hard time in some encounters. Especially when they're up against spells like Cone of Cold which does alot of damage in a huge area and Dominate Person which is literal mind control to NPC's.