As for the 5000-8000 figure, that came from conversation with Ron Moore, and he claimed it sprung from some DS9 writers' room discussions on the topic. While his contribution on tech issues is usually nil, I think it's a solid figure
I've read that Moore also considered that Starfleet could be up to 30,000 starships.
If you think about the vastness of space and how the Federation covered or explored roughly a fourth of the galaxy, they should have at least 8,000 ships to defend themselves. But my guess is that before Wolf 359, they weren't serious about ship building.
In TNG didn't they say the Federation only had explored a tenth of the galaxy? Maybe it was in a book or something.