Depends. In TNG the outlook tends to be far more rosy than in DS9 or DIS. There were a few episodes which hinted at darker tendencies in Starfleet but those usually turned out to be corrupt individuals or some kind of alien influence.
Having grown up with TNG my impression of the Federation was much like what the US was pretending to be prior to 9/11 (i.e. prior to "world police"), a beacon of liberty, equality and hope for mankind, but with all the ills of real-world USA eliminated by scientific progress and a more idealistic and altruistic society.
The show had a few militaristic undertones initially but they mostly went away in season 2 and later, except for the ranks. The ranks and offensive capabilities are lampshaded a number of times but Picard and other characters frequently prove that those are just born out of necessity and for self-defense, never to attack. The Borg represent such a threat exactly because they are not interested in diplomacy and Starfleet has to fight an all-out war to survive them -- unlike the Romulans or Klingons who even at the worst of times mostly didn't outright attack them.