This is not my experience. The martial classes in my last game were better than the optimized caster.
It depends on a lot of things. Focus on DPR? Well, do you have a 5 minute work day and have a lot of relatively low level monsters always showing up in fireball formation or do you have relatively low number of monsters that can't easily be targeted simultaneously. I play Solasta now and then (it's a D&D based video game that tracks DPR over several levels) and fighters have effectively always come out on top even with frequent long rests. Yet for some reason I was told that it doesn't count even though it more accurately implements the game than BG3. Why didn't it count? Not sure, I assume because it doesn't fit the expected narrative.
Utility? Well, how much is it worth to be able to teleport from A to B and is the teleport required only because the DM knows you have teleport? Make scrying more powerful than just a magical drone pointed directly at your target from 10 feet away? Does the scrying show something useful instead of the target eating lunch reading some papers you can't see? Cast dimension door to get across a chasm that the rest of the party can't cross? Great. Have fun fighting the enemies by yourself.
A lot of the caster supremacy seems to be either confirmation bias or white room analysis assuming the caster always has exactly the right spell prepared and spell slots available. Then again, other tables play differently. Just because I've never seen it with a couple dozen different groups at various levels doesn't mean it doesn't happen sometime somewhere.
In my experience, the classes are different, sometimes one PC shines sometimes another. Sometimes the fighter just keeps plugging along doing more than anyone else but it's slow and steady so people don't notice.