Strictly a marriage of convenience! For Hitler, keep Russia out of the situation until we are secure in the West. For Stalin, get my share of Polish real estate – which also just might be a buffer once this maniac gets set to attack me!
For an eye-widening experience, check out the film “Alexander Nevsky” (silent B/W) in which Russia is a loosely defined territory, circa A.D. 1000, and this prince Nevsky must rally the people and soldiery to halt an invasion by… none other than the Teutonic knights – wait til you dig the bizarre yet strangely familiar helmets on these early German horsemen! Then there’s the amazing clash of mounted armies on the frozen lake (Ladoga?)
Anyway, Russia has been invaded by swarms from the west since time immemorial. Stalin knew that, regardless of any warmer recent relations. Your point is nevertheless well taken F_alk, because there must have been open and somewhat cozy lines of communication for the secret pact dividing Poland to have been established. And look at relations since 1945: Germany and USSR were always ahead of the rest in doing business across the Iron Curtain. I maintain that geography is destiny: As the main economic power in Europe proper, due in part to its central location, Germany would always be the logical partner with a westward-looking Russia.
((The real way for Hitler’s Reich to have staying power would have been to keep Russia on its side – how about THAT as a topic: how would the African and Balkan fronts have worked out, not to mention the plans to take down Britain, had Berlin-Moscow relations remained cordial? A chilling prospect.))