This was thanks to the Non-Aggression Pact signed with Germany, which in a number of secret protocols in the treaty assigned spheres of influence in Eastern Europe between the two nations.
Stalin could move against them in full knowledge that Germany wouldn't interfere