This question already has an answer here:
EDIT: I don't think it's a duplicate of this. That question asks why attack USSR while still fighting Britain (and I think the OP has a misunderstanding there because the Battle of Britain was already over and Britain did not mount much offensive power for a while after that). Also, my question is about Germany attacking USSR and Japan attacking USA. I'm asking what seems to have obligated them to this, such as prior agreements.
From a related question, I started wondering (again) why Germany ever invaded the USSR. At the time, the Molotov–Ribbentrop Pact was in effect wherein Germany was greatly supplied by Soviet material. Why would you cut off this supply AND open up the huge eastern front?
That said, let's say the Battle of Britain ended the same way and Germany has no way to invade Britain. Can't the Germans just take some breathing time and consolidate their power in West and Central Europe? Instead, something seemed to obligate them to attack USSR immediately. I cannot figure out what this "something" is.
Taking this further, if the Japanese did not bomb Pearl Harbor, then America would not have gotten involved any time soon. They seem to have felt compelled to attack America. I know they were trying to destroy the US Navy, but honestly, if you can't touch the North American mainland, they must surely have known the Americans would rebuild. So I don't see what really compelled them to attack.
It sounds to me in this situation, without attacking USSR or USA, the German and Japanese Empires would have been very stable for at least...5 years or more. There would be action between Britain and European continent, but nothing decisive. It would be stalemate there, maybe with an official truce, but stalemate at the least.
(I know about the A-Bomb too, and even if we assume America is still the only one working on it and would have it in 1945...they can't use it without air superiority. We could I guess wait until 1955 or 1960 for an ICBM, but what would Germany/Japan have by then too?)
To sum up, what really compelled Germany to attack USSR and what really compelled Japan to attack USA? Were they really obligated under some treaty or internal agreement somewhere?
I don't know if ideology can explain it. If your ideology says you have to conquer the world, then why not do it in an actual realistic way like the one I mentioned? Instead, it's as if they had some unspoken short-term deadline for all of this.
EDIT 2: Let me try to clarify a bit more: To me, it seems like there was some internal agreement saying, Hey i'll take USSR if you take USA! Otherwise I can't understand why, at the very least, both Germany and Japan didn't cooperatively attack USSR from two different fronts. They could each concentrate on one front, whereas USSR would hafta deal with two.