Not everything is post-scarcity, mostly food and clothes. Land, fuel, weapons, art, fame, and labor are still limited resources in the Star Trek world. Also, not everywhere is post-scarcity, as we see many "poor" or restricted societies. The post-scarcity bit is mostly about a social safety net for individuals in the Federation.
Even within the Federation, colonies can collapse and fail, experience famine, plague, etc. Tasha Yar came from one such colony that had regressed into violent anarchy.
The Federation is a post-scarcity utopia until the writers want something interesting to write about. Then the Federation gives some colonies to the Cardassians and you get the Maquis.
> The Federation is a post-scarcity utopia until the writers want something interesting to write about.
Similar to Iain Banks' Culture novels. The Culture is so utopian that there is no interesting conflict, so all of the action is driven by contact with less developed civilizations.
(You talk about the Federation itself, but IIRC Star Trek also often deals with external forces - in any case, "everything is great" isn't interesting for long)