Quite - we must also remember the Federation is a democracy and democracies are generally quite poorly prepared for war. Even if we work on the assumption that the Federation is significantly technologically advanced and resource rich that market forces as we know them do not exist (which is reasonable) there will still be some decisions to make on distribution of resources.
It is unlikely Starfleet is allowed a standing fleet of thousands of warships sitting in dockyards waiting for war, no modern navy is after all. They probably mothball a lot of ships in peacetime, and have facilities specifically designed to ramp up massively in the case of war.
"In peace, prepare for war" is a much misunderstood concept and does not necessarily mean having massive standing forces. It means having scalable infrastructure and abilities that can grow quickly when the worst does come.