What you are discribing is the experience of many socialists in the years surrounding World War I. Mussolini himself, a socialist before the war, went through such an evolution. Gramsci and his other colleagues reviled him for putting nationalism above class-consciousness. Mussolini didn't need Gramsci to tell him what to do. Gramsci and others were commenting on what Mussolini was already doing and there was a rich Italian tradition of Machiavellianism for Mussolini to draw on.
Gramsci and Mussolini came out of a similar enviroment: early 20th century socialists and Marxists read Nietzsche, Bergson, Sorel, and other "new thinkers" and acquired, or at least encountered and explored, an interest in myth, the will and the irrational. Machiavelli also was widely read, analyzed and applied by intellectuals across the political spectrum. The national passions stirred by the war further influenced the thinking of the day. The conclusions drawn varied widely, though. Hitler was influenced by this mix, but at second hand. Later those who wrote about ideologies ignored the common soil of the era in which a variety of ideologies took seed.