The Soviets would have needed friends if the Allies accepted German's surrender then immediately took control of the German military to destroy the USSR, and Japan was in a natural position to be that friend.
Stalin only agreed to break the non-aggression pact once it became clear that no invasion from the west was coming, which was fairly late in the war (Yalta).