- Those countries were poor and without sufficiently established democratic institutions.
- Those countries had to immediately mobilize to defend from richer capitalist countries (lead by the US) trying to undermine them in any possible way. Constant defense mode leads to totalitarianism.
That doesn't mean that socialism requires totalitarianism by nature.