Federation strategy is different from its competitors. That is what gives the Federation a competitive edge. Many of its competitors emphasize expansion by military force. The Federation maintains a formidable military force but emphasizes expansion by diplomacy as a countermeasure to competitor expansion. We are looking at two sides (strategies) of the very same coin (imperialism).
Both the charter of the UFP and its Prime Directive embody policy that demands an equal and opposite reaction to the imperialism of its competitors. For example, see the TOS episode “A Private Little War.” It is the very necessity of becoming like your enemy in order to defeat him, or preventing him from doing further damage to yourself or others!
Now, as to “empire,” the United Federation of Planets is exactly that. It is a massive commercial empire of planetary union states that voluntarily submit independence to the authority of one governing body. Again, Federation strategy is different from its competitors. Many of its competitors pillage and rape the economies of subjugated worlds in order to add to the wealth of the governor or governing body and its military force. The Federation maintains massive wealth but shares technological developments that help bring members up to par with a united economic standard all the while maintaining a formidable military force. Again, we are looking at two sides (strategies) of the very same coin (imperialism).
Actually, species that join UFP do not seem to 'submit independence'. They simply become a part of a larger whole... a growing community of sorts that shares similar views and benefit from a non-monetary socio-economic system where open sharing of resources, science and technology is commonplace (as is emphasis on equality, equity, etc.) - main purpose of which is to become better than what they were before.
In essence, species in UFP get a chance to get to know each other and live among each other as they would on their own home planets... no restrictions on travel, living or even contributing to society as a whole, no fear of internal wars, no restrictions on inter-species coupling either (unless there's a biological barrier... but even then the UFP will try to break through that barrier and make it possible).
And while some newcomer species may take time to adjust, the criteria a species must meet for joining the UFP at large is probably why its there. To give the planet time to adapt to the notion of UFP - and not only that, but various individuals are likely welcome to experience life in UFP (similar to how we saw in the Kelvin Timeline on the Yorktown starbase - I'm pretty sure the exact same design exists in the Prime timeline too and is used for the same thing though).
What's also interesting is the fact that UFP as such doesn't dictate policy on the member species homeworlds... that's left to their local governing bodies as its always been - and as such, if a species runs things in a given capacity, UFP won't interfere with that so long as it doesn't hurt societies and individuals at large.
Furthermore, while majority of whatever space craft and habitats a spacefaring species has does become absorbed into Starfleet, those who have no ties to the local space agencies or militaries of their home planets retain their independence.
Even Vulcans were shown to still have entirely Vulcan run ships under the high command (not Starfleet). However, officers can still be freely be transferred from one to the other if a decision is made.
Also, as its been demonstrated in Trek, humanity learned that large (and hostile) empires exist and will probably do whatever it takes to expand eventually everywhere and conquer things by force.
Independent species might not be able to stay independent and retain their freedom unless they join the UFP. And this isn't something the UFP is forcing either.
Its just how the galaxy was shown to work in Trek.
So, UFP is there and it allows species the ability to maintain their freedom while becoming a part of a larger whole.
Oh and we also have examples in Trek where a species was DENIED joining the Federation because the situation on the planet was bad to say the least. The planet was anything but unified and hadn't really worked together.
If UFP was truly imperiealist, wouldn't it try to absorb pre-warp species?
We know UFP doesn't do that. It may study them yes, and is there to initiate FC procedures when they achieve FTL capacity... but otherwise, if they want to be left alone, the UFP leaves them alone.
As for the Federation maintainging a formidable miliary force.
It was already mentioned by several SF officers that SF is NOT a military organisation. They just don't see themselves like that.
Its a defensive and exploratory arm of the Federation.
Also, just because SF has tens of thousands of ships in the 24th century, it doesn't necessarily make it an empire.
The number of ships is there for exploration and defensive purposes only.
They use weapons purely for self-defense (aka, they don't fire first).
And to be fair, the Milky Way in Trek if filled with hostile species as is... UFP would need an adequate amount of starships to protect itself and continue its exploration efforts.
I think people are too bogged down with current day descriptions and try to transpose those on Trek and UFP because that's the only thing they are familiar with for the most part.
Heck, usually when SF was described in militaristic terms, it came from other species (the Klingons, Cardassians, romulans and Dominion for example)... not SF itself.
And to be fair, those other species are highly militarized and imperialistic.
A distinction needs to be made... so I don't think its as simple as saying the UFP is another side of the same coin.