I mean, from a hull role design perspective the Galaxy and Ambassador classes were both failed designs. Consider how long the various hulls served as an Enterprise:
NCC-1701 (Constitution/Constitution Refit): 2245 - 2285 = 40 Years
NCC-1701-A (Constitution Refit): 2286 - 2293 = 7 Years
NCC-1701-B (Excelsior): 2293 - 2337 = 44 Years
NCC-1701-C (Ambassador): 2337 - 2344 = 7 Years
NCC-1701-B (Galaxy): 2363 - 2371 = 8 Years
These are some damning numbers for the Ambassador and Galaxy hulls. Both the Constitution and Excelsior Enterprises saw around a 40 year service span, the Excelsior-class hull saw an over 100 year service in the Federation Starfleet, and proved to be a highly reliable and upgradable design able to support even very advanced weapon systems like Quantum Torpedoes and high end phaser arrays.
The Galaxy and Ambassador classes both were supposed to replace the Excelsior as the premier heavy cruiser of the Federation... and considering how quickly both were phased out for newer designs in that role, while the Excelsior stuck around... it seems neither could really fulfill the role as envisioned by Starfleet.
I'm a bit less sold on that, given the real reason the Excelsior "stuck around" for so long was because it took the show until like season 4 to get the budget for a new model miniature, and until then they were stuck with just the ones they already had on hand. In universe, yes the Excelsior design stuck around, but I think you're overstating it's length of service as the premiere starfleet cruiser. Yes, the design is long lasting, but by the 24th century they're second or third line ships, with Galaxies, Nebula, and Ambassadors serving out on the frontier (also, the Miranda is still in service during the same period, and I don't think anyone would classify
it as the pinnacle of Federation starship design).
And judging the class by how long thier respective Enterprises is a very poor metric. The C was destroyed in action fighting at 4:1 odds against peer opponents, saying it's a bad design because it lost that fight is tremendously unfair (do we have any reason to thing the B would have done any better there?). Likewise for the D, which per All Good Things could have been cruising along just fine in 2395, and was destroyed only through deception and tactical incompetence/the need to get it out of the way and replace it with something more suited for the big screen.
In terms of how long a design lasted until it was superceded by a newer design (based on non-canon sources, granted, as the show itself isn't very precise avout this), the Excelsior is still long lived, but not quite as impressive as you suggest, it only just outlasts the Ambassador:
Consitution: 2244-2285 (41 years)
Excelsior: 2285-2325 (40 years)
Ambassador: 2325-2357 (32 years)
Galaxy: 2357-2370 (13 years)
Sovereign: 2370-2380 (10 years)
Oddessy: 2380-2410s (30 years and counting)
And frankly, the fact that the Excelsior lasted so long is, in my opinion, merely a side effect of Starfleet's design priorities at the time. It happened to enter service just as the Constitution was entering the end of it's viable service life and as the detente with Klingons was forming. Once that started to fade, the Ambassadors were rolled out, and when startfleet freaked out over the Borg and Dominion and started really pushing starship development, the design turnover rate increased rapidly. That doesn't mean older designs are just so much better, it means there wasn't as much pressure to improve and replace them (and a number of entirely out of universe production factors).