It’s not surprising that Nazi would make compromission with Soviet Union, their so-called biggest enem because that non-invasion pact let those two nations both benefited.
For Germany, the pact released it from the threaten to face two long battle lines in West and East and temporarily avioded the formation of a larger anti-Germany alliance which included Soviet Union, England and France. In fact in 1939 Soviet Union, England and France had an negotiation in Moscow as well. With this pact and the appeasement policies of France and England, Germany further expand it’s sphere of influence and divided Poland with Soviet Union which made it more prepared for the invasion to the whole Europe.
For Soviet Union, this pact let it had time to recover it’s millitary force which had been deeply damaged in counter-revolutionary elimination because too many experienced generals been persecuted. In the Soviet-Finnish War in 1939, the weakness of Soviet army been exposed. When Germany invaded Soviet Union, it’s army had reorganized and showed considerable strength. Moreover, by annexing other countries in east Europe, Soviet Union expanded it’s depth in defense and made the invasion became more hard.