Germany expected Japan in return to help them against the Soviets.
The Japs weren’t stupid.
Perhaps as a long term strategy
But This plan for Japanese control of the Pacific was foreshadowed in the 1920s
Germanys preoccupation in 1941 was not with eastern Russia but with combined German-Russian hegemony over the Eurasian heartland
Heavily influenced by Haushofer
Hence Hitlers insistence over his advisors on opening a Russian front
https://thediplomat.com/2017/12/this-1925-novel-inspired-japans-attack-on-pearl-harbor/
The Japs werent stupid.
The Germans weren't paying attention to the shift in power between the army and navy factions in Japan's military, back during the WWI and interwar periods. At one point, Japan's army was ascendant - and it wanted to secure a big chunk of Russian territory and eliminate the Russian threat on the Sea of Japan. The Russians and Chinese had some luck during two or three key land battles and the Japanese army lost ground.
With its Navy faction gaining power, Japan started formulating "Plan B" - securing the Pacific Rim to the south.
As I recall the “strike north” faction got their wish in 1939 with an attack on the Soviet Union. At first it succeeded, but then the Soviets reorganized themselves and chased the Japanese out. The Japanese really got their fingers burned with the Soviets. From then on the Japanese would have nothing to do with the Soviets no matter how much the Nazis implored them.
It was just a matter of days after concluding the nonagression pact with the Japanese that the Soviets felt confident to attack Poland.