In all the actual examples I can think of, the totalitarianism came first. Eastern Europe mostly had socialism imposed by an occupying force, and that same force also imposed totalitarian governments. In other places, Communists took over, set up a totalitarian government, and then proceeded to implement whatever they thought socialism/communism entails.