Yeah, the pathfinding is just... not great in vanilla Skyrim, especially on PS5 where you can't mod it out. Lydia's particularly bad because she's scripted to be aggressive in combat and doesn't have the sense to step back.
Your best bet without mods is honestly to lean into ranged or magic so you're not competing for the same space. A pure mage setup where you're slinging spells from 30 feet away while she's up front swinging means her AI stupidity stops being a problem - she's doing her job, you're doing yours, and doorways don't matter. Alternatively, play a bow-focused character and position yourself behind her or to the side during fights.
If you want to keep her but minimize the annoyance, try dismissing her right before entering tight dungeons and picking her back up after. I know that's tedious, but some players do it just to avoid the doorway shuffle.
The followers with supposedly better pathfinding (like some of the ones from the DLC or questline recruits) are marginally better, but honestly they all have the same core issue - the engine just doesn't handle companion AI well in cramped spaces. It's a limitation of how Skyrim's movement system works.
On PC you could grab mods that overhaul follower AI or just use a mod that lets you teleport followers to you, but you're out of luck on console. Sorry - it's one of those things where vanilla Skyrim's design just doesn't play nice with what players actually want.