I'm not quite sure what you mean, sarah. Hitler (Germany) and Stalin (Russia) had a non-aggression pact which it's widely understood neither intended to stick to. Hitler got in first by invading Russia in 1941. From then on Russia was in the fight against Hitler right up to the end of the war in Europe in May 1945. It was the Russians who actually conquered Berlin.
In the First World War, however, Russia started off being involved against Germany, but when the Russian Revolution broke out in 1917 one of the early acts of the Bolsheviks was to pull Russia out of a war that was extremely unpopular with the ordinary peasants who were doing the fighting and dying. I believe they signed a treaty with Germany in 1917.
Or are you perhaps thinking of how Russia changed from being an ally in war to being the "enemy" in the ensuing peace. That was because Stalin's Communist regime grabbed as much of Eastern Europe as it could at the end of the war, and ran it with an iron hand. Stalin was perceived as wanting to take over Western Europe as well. He and his subject peoples formed the so-called Eastern bloc (no k), while we in the West formed NATO as an alliance to counter it.