Stalin ignored warnings of the Nazi invasion. After the British warned him, anyone telling the psychopath the truth was at risk of getting shot as a British agent. Stalin believed the Nazis, when they claimed to be moving forces east to protect them from British bombers. (At this stage of the war, British night bombers were lucky to inconvenience the proper city in an attack.) Stalin then increaed and sped up oil deliveries to the Nazis. Stalin responded to the invasion with a nervous breakdown. He should have been sacked after hiding in his dacha for a week. However, every communist leader with any ability to do so had been assisinated or convicted of treason. Stalin's war orders were horrible, leading to armies being surrounded. Fortunately, Hitler was no more competent.
Yeah, no kidding. The guy was a psychopathic murder, and many times extremely incompetent as well. I wouldn’t even be surprised if Stalin ended up doing what Hitler ultimately did when the Nazis were obviously about to lose had Hitler succeeded in invading the Soviet Union (in other words, blow his brains out), and he arguably came very close to doing so based on how he hid at his Dacha, similar in fact to how Hitler on his last days hid in a bunker and then committed suicide.
Ironically, however, there was evidence pointing to Stalin trying to subvert Hitler and planning to backstab him (and in fact, their “alliance” and letting Hitler run wild on Western Europe was meant to buy them enough time to rebuild their forces), but Hitler beat him to the punch in turn.
Of course, the Soviets pretty much WANTED a war, Stalin included, believing THAT would be prime breeding ground for forcing in Communism, as you can read here: https://www.fff.org/explore-freedom/article/setting-record-straight-stalin-used-hitler-start-world-war-ii/ That’s also another reason he wanted to fight Hitler, just to create the conditions necessary to push Communism, and he implied that Lenin had similar plans in mind.