Why are there such an abundance of Excelsior class ships in the late 24th century?
To answer that question, let's talk about Starfleet's expectations for a new class of heavy cruiser/explorer. The Constitution class was in service for at least 50 years. NCC-1701 was commissioned in 2245, but it wasn't the first Constitution class ship. So lets say that the first one was launched in 2243. They were in service until at least 2293, but probably even later than that. It also had three significant refits over the course of it's 50-year service life.
The Excelsior was commissioned in 2290 after the great experiment failed. By 2293 it was Starfleet's pride and joy, and the first Federation ship named Enterprise that wasn't a Constitution class was an Excelsior. The basic Excelsior frame is apparently extremely durable and versatile, since Starfleet began producing them en masse.
It was Starfleet's biggest, meanest ship for about 20-30 years, from the 2290s until the 2320s. This mirrors the Constitution's service life as well. When Starfleet designs a new front-line heavy cruiser/heavy explorer, they apparently expect it to serve for at least three decades in that capacity, and then at least another two as an auxiliary cruiser/explorer.
The Ambassador was clearly slated to replace the Excelsior as the pride of the fleet. But for whatever reason, the Ambassador didn't have as privileged a run as the Excelsior.
Why?
Politics.
In the early-mid 24th century, the Federation didn't have many enemies. It was a time of relative peace. The Romulans had withdrawn behind their own borders, the Klingons were still recovering from Praxis, the Ferengi were unknown and the Cardassians were upstarts. They didn't really need another big mean ship like they needed the Excelsior in the 2280's, at the height of the Federation-Klingon Cold War.
Furthermore, because the Federation is in such a strong position relative to the other galactic powers, Starfleet has returned to it's original mandate: exploration and humanitarian operations.
Think about it from the perspective of the admiralty. The year is 2340 and you're the admiral with ultimate authority over the construction orders at all of Starfleet's various shipyards. The situation is as follows:
The Rear and Vice admirals commanding fleets out of frontier Starbases tell you they need more ships to support the expanding Federation border.
The Romulans are quiet.
Peace negotiations with the Klingons are proceeding smoothly, especially since Capt. Garrett gave her life, ship and crew to defend a Klingon outpost.
First contact with a race called the Cardassians has occurred recently. They have some bad blood with the Klingons due to a dispute over a dilithium-rich planet in the Betreka nebula, and the Klingons are our allies now, and they might require our assistance. However, all intelligence on the Cardassians indicates that they are several decades behind Starfleet in terms of technology and they don't appear to be catching up to the Federation's tech level.
So, Admiral, Utopia Planitia wants to know: what are we building for the next few years?
Build more Ambassador class ships. The Ambassador class design is about 15 years old now, tried and true. Ambassador class ships are expensive, both in terms of time and material. However, they easily outclass the known Cardassian counterparts of the time. On the one hand, building more of them would be a potent show of force, but on the other hand, we need a larger fleet more than we need tougher ships.
Or,
Build more Excelsior class ships. The Excelsior space frame is aging at this point, over 50 years old. But the Excelsior class is one of the most successful ship classes the Federation has ever built. They are durable and easily refittable, and they have enough internal space to be fitted for a wide variety of missions. In fact, the Excelsior herself is still in service at this time, 50 years after her commissioning. Unlike the Ambassador class they are no more powerful than Cardassian counterparts, but we have perfected the manufacturing process at this point and we can build a lot of them cheaply and quickly, and we need lots of reliable, speedy ships to support our growing network of colonies.
The choice is pretty obvious. The Ambassador class, despite being a better ship by just about every measurable metric, gets sidelined. Meanwhile, Excelsior production accelerates because the Federation needs more ships. This is why, by 2365, there appear to be more Excelsiors in service than Ambassadors, despite the fact that the design is 80 years old.
I always took the view that while the Ambassador class was a good, proven ship design which pushed starship innovation further for Starfleet (first ship with phaser arrays) it was costly and time-consuming to produce compared to its older brother in the Excelsior class.
Starfleet has a lot of time and experience building the Excelsior class, and likely has the production process all but perfected and can crank them out quickly and efficiently, unlike the Ambassador.
Then at some point, Starfleet started to mess around with a new era of ship that eventually cumulates in the Nebula/Galaxy class ships. During this process, however, the design RnD come up with some smaller but useful ships that are just as effective if not more so than the Ambassador in many different roles.
These ships are the New Orleans, Niagara, Springfield and Challenger class ships.
It's inevitable that Starfleet is going to shift a part of its difficult Ambassador production over to these new ships that are getting the job done with less time, manpower and resources, not the easier to produce Excelsior. As a result, the Ambassador is slowly sidelined.