It depends on the specific classes involved
High-level thieves get extra turns. Going first is a big deal, going first and second is a huge deal. They can also use some otherwise restricted magic items that can be extremely powerful-- for example a thief with a Tome of the Stilled Tongue can, with preparation and at most once per day, cast any spell as a bonus action instead of normal. So a thief might be able to cast True Polymorph except it's quickened, which is pretty clearly better than casting True Polymorph but it's not quickened-- it being quicken means the caster could use their first turn in a surprise round to cast the spell and turn into an adult red dragon and then fly over and fire breath the enemies and then take a second turn where they multiattack the surviving enemies. A druid, for example, would instead only be able to attack on their next turn after polymorphing.
High-level Fighters get extra actions. An adult red dragon may get 3 different very damaging melee attacks each round totalling 2d10+6d6+24 possible damage, but a 20th level Battle Master gets four attacks per action and can action surge to get two actions. That's 6d12+16d6+40 possible damage in one round if they decide to pour all their resources into a single fight. Furthermore, in addition to dealing more than twice as much damage, the Battle Master can apply all sorts of different effects on up to 6 of those hits. For example, they could attempt to push a Large or smaller creature up to 90 feet backwards with a longbow, in addition to that damage. And if they have a magic weapon or ability score increasing magic, that damage will be even higher.
High-level Zealots are nearly immortal. While an adult red dragon has quite a few hit-points, the Zealot has 0-ish hit points but "While you're raging, having 0 hit points doesn't knock you unconscious... if you would die due to failing death saving throws, you don't die until your rage ends, and you die then only if you still have 0 hit points." and "your rage is so fierce that it ends early only if you fall unconscious or if you choose to end it." This means only effects that specifically knock the target unconscious (like sleep for non-elves) or directly kill the target (like Power Word Kill) can kill a high-level Zealot. And even then, raising them from the dead is free. While they aren't super sticky, they do still do quite a bit of damage, and it's not like the Adult Red Dragon spellcaster is any stickier.
A 20th level Kensai does comparable average damage to the Red dragon, though not nearly as much as the Battle Master. Specifically, they do as much as 5d10+32, but they also have advantage on all 4 of their attacks, can reroll a miss, and have a higher attack bonus, so that actual average damage is a bit higher than it might look. Monks do struggle to keep up at high levels, in general, though.
If paladins and rangers count as martial characters, they can keep up pretty well as well (unless you are a Beast Master). The ranger does that in part via spells like Swift Quiver, while the Paladin does that mostly because their lower-level features can nova pretty well-- high levels of paladin don't add very much besides spell slots.
Now, while almost any class can keep up with an Adult Red Dragon sans legendary actions at 20th level, that doesn't mean that they can keep up with a spellcaster at 20th level. A 20th level Wizard can be just vastly more powerful in every way than a 20th level monk. Battle Master fighters and Thief rogues can keep up in combat, because Fighters do absurd amounts of damage at high levels and Battle Master maneuvers can apply many useful effects chosen for the situation sort of like spells while for the thief extra turns really are that good, but actual spellcasters have their own class features that make their abilities better than just casting True Polymorph generically.