First of all this were USSR-Japan skirmishes not war, second they did not have to worry about Japan as was shown by Soviet–Japanese Neutrality Pact of April 1941, third if they were worried about Japan then "spending" army on invasion of Poland, Finland, Baltics, Bessarabia were counter productive, fourthly at the time of Ribentrop Molotov pact Britain ceased following appeasement strategy as shown by declaring war to Germany at 3-rd of September 1939 as fulfillment of security guarantees given to Poland in March of 1939.
It is totally ahistoric to pin any actions of USSR on fear or just reaction to external events. If WWII was continuation of WWI (in my and many opinion it was) both Germany and USRR were revanchist powers that wanted to reverse outcome of WWI. Many forgot that Russia later USSR lost WWI badly. Plus Stalin after very, very, bloody consolidation of power in 30ties was ready (in fact it was imperative for regime stability) to start outward aggression/expansion.
Furthermore historian believe that Stalin knew that confrontation w/ Germany is inevitable but (more popular opinion) was estimating it will happen one year later at least or (less popular, even fringe opinion) was amassing forces to attack Germany and was cough by Nazis w/ "pants down". Either scenario would be explanation for initial successes of Operation Barbarossa.
Fun fact - last train with grain from USSR to Germany crossed border few minutes before start of Operation Barbarossa.
In summary - Soviets and Nazis were allies till 1941 - both parties know it was tactical alliance not unlike USSR - GB/USA against Germany and at the very end Japan. Note that after WWII there was cold war between former allies - not unlike like hot war between former alliance parties of Nazis and Soviets.
Second fun fact: Orwell's "oceania was always at war with eastasia" from 1984 is direct reference to how alliances were changing during WWII.