The Federation is Socialist, but Star Trek is not a Marxist piece of media.
It follows a Liberal, Democratic-Socialist, Reformist line of thinking - that, at least once the world has been shocked by the brutality of global war and eugenics - Humanity will "come to it's senses" and move towards Democratic Socialism through reform. When post-scarcity is achieved, the Capitalist class will just let this happen.
It is a Socialist world devoid of the ideas of class conflict; it presents a world compatible with Socialist ideals but not one compatible with scientific Socialist theory.
That's not to say you can't still like Star Trek as a show or use the Federation as an example of a good Socialist society. You just have to keep in mind that the world's history does not make sense when viewed through the lens of Marxist class conflict.