I think the Trek universe morphed to whatever each episode needed to advance its plot. There is also the issue of what "socialist" means, since there are several incompatible definitions. Several episodes of the original series definitely revolved around economic individualism, such as the...