By signing the German-Soviet nonaggression pact Hitler hoped

to have the help of the Soviets in order to invade France.
to stop Britain and France from declaring war
to force Stalin to attack Japan
to avoid a two front war

to avoid a two front war