First, it's important to understand that the "alliance" between Nazi Germany and Imperial Japan was essentially in name only. The two powers offered little more than rhetorical and spiritual support for each other. There was no actual strategic coordination between the two. The Germans did what they wanted, and the Japanese did what they wanted.
Next, there was actually intense debate in Japanese circles about which direction to take for expansion--north and west against the Soviet Union, or south and west against the European colonial powers and the United States. The Japanese Army favored the former approach, viewing it as the natural outgrowth of their campaigns in Manchuria and China. Despite a serious defeat suffered a few years previously in a "border incident" called Khalkhin Gol (and fought in Mongolia), the Japanese army felt fairly confident about their ability to smash what remained of the Soviet Far Eastern Military District (the cream of which had been sent west to save Moscow from the Germans in Barbarossa).
In contrast, the Navy favored the latter approach, coveting the natural resources to be found in the South Pacific and wishing to establish a protective ring of naval and air bases designed to eliminate western interference and secure their empire from the growing influence of the United States in the region.
In the end, the Navy's plan won out, and the rest is history.
For further reading, and in my opinion the best overall work on the Pacific War, see Eagle Against the Sun: The American War with Japan by Ronald H. Spector.
This question was basically asked about two days ago and a decent answer was given. https://www.reddit.com/r/AskHistorians/comments/567mny/why_didnt_japan_attack_the_sovie_union_during/