My dad had this question and I told him scifi.SE would have an answer.
The United Federation of Planets contains 150 planets-worth of civilisations. This includes Humans, Vulcans, and many others. Presumably they would have a massive capacity for producing warships if need be.
The Klingons are a standalone race, with a single planet as their homeworld, and perhaps some outposts and colonies. Sure, they like war a lot. But can they really compete with the Federation in production of warships?
What about the Romulans? They have two homeworlds... but really, how can they really pose a threat?
I realise that this is a very simplistic way to look at war, even from a historical perspective. But looking forward to hearing what people have to say.