While reading a Cracked article, I saw a Star Trek pic that was just all kinds of wrong...
This photo is inaccurate. Losing 39 ships in battle against the Borg at Wolf 359 did NOT leave Starfleet without enough ships to defend the Federation. Starfleet just had so many ships spread out across the galaxy that 39 was all they could muster on such short notice.
Also, they probably built more than a few hundred ships between the Borg Incursion of 2366-67 and the Dominion War in the 2370's. If you remember the battle this pic refers to from the DS9 episode 'Sacrifice of Angels', you might remember Sisko referring to 'Galaxy wings 91 and 93.' That means there's at least 93 wings of Starfleet ships being led by a HUGE Galaxy class starship in the fleet at that time.
Considering that, I'd say that Starfleet put themselves on a war-time footing with ship building after the Borg incident in 2366-67. How else would they have so many ships already in service at the start of the Dominion War? And they must have really ramped up production on Galaxy class ships, too. When the Enterprise NCC-1701-D was launched in 2363, there were only going to be 6 of that class in service. It was so powerful that Starfleet decided they only needed that many. And then, the Romulans came out of decades-long seclusion... The Klingons started getting antsy... The Borg show up... And the list just goes on from there.
And how did Starfleet build so many in only a few years? Well, you have a nation-state that spreads out over 8,000 light years of space with trillions of citizens and they're a Type-2 civilization on the Kardashev scale. Quickly building enough ships to defend the Alpha Quadrant from would-be aggressors would not be an insurmountable task to them. It would probably be analogous to the United States ramping up production of war materials during the War on Terror: VERY costly but, also quite doable.
- Lord Publius