It's known the USSR was caught off guard with Germany's 1941 invasion. However throughout 1940 when Germany was rolling through almost all of of Western Europe and with Hitlers past statements on Lebensraum.
How could they have not realized he'd be turning east at some point?
They did. Stalin specifically knew that Nazi Germany would march East, at some point. However, the surprise of Operation Barbarossa was not that it was coming, but how soon. The Soviet high command expected the Invasion even while signing the Molotov-Ribbentrop Pact. In 1940, a year after the Pact was signed, Stalin expected an invasion saying that the Soviet's "...will try to delay the war for another two years." The issue was that the Soviets had to be prepared while not giving the Germans a pretext for war, as in a build up of military on the border that could be perceived as an invasion force, thus starting the invasion too early. In essence, Stalin knew Hitler would try to invade, but he had to make it seem like he really didn't, so as not to tip the Soviet's hand too early. All during the three years of the Pact, the Soviet Union had plans made for the eventual invasion, and possibly (although debated), an invasion of German lands. The caught off guard was not that Germany invaded, instead it was the time and with such force. Operation Barbarossa remains the largest invasion in the history warfare, with more than four million Axis forces crossing into the Soviet Union. The Soviet Union suffered massive losses in the first days, such that it would seem they were caught off guard.