i believe by "tribble guy," they mean the merchant who was selling them, not the Klingon spy the tribbles outted.
and i seem to remember a good many instances in TOS and the movies where Kirk and others proclaimed the uselessness of the accumulation of monetary wealth in current Earth society. which is what's mentioned in TNG, too. so it's most likely that it's not the Federation, but EARTH and affiliated human colonies that's a SOCIALIST society, not communist. communism is a perversion of socialism which tends to involve dictators, FYI. a good number of Federation members in TNG and DS9 have shown a penchant for accumulating wealth, so that rules out the Federation as a whole being socialist or communist.
so the Federation is something its name is based off of: a Confederation. which is a very loose democratic nation that places emphasis on the rights, laws, and customs of the various member states over the larger federal gov't. each of the states is granted a great amount of freedom as to how they set up their society. so humans went the socialist route while, say, the Orions (the Federation members, not the pirates) like capitalism. as long as the will of the people of the member state is not being oppressed, it seems like the Federation government doesn't really care how you do things.