The US and Germany were both helping fight back against the communists in China and Spain. Everyone was basically on board with being against the communists, they just weren't on board with the extremes to which Japan and Germany were going. Japan was passing laws to suppress Marxist revolution in their country in the 1920s and Germany went to many extremes, routing out communists anywhere.
In Germany you even saw education being changed to fortify new students as anti-communist, because preventing communist revolution from taking over Germany was existential for them. The teachers knew what they were teaching, but they were afraid enough of communism that it seemed a reasonable defensive mechanism. There had already been examples of communist revolution upending countries, so it wasn't as if it was a fake threat or concern.
It was very real, and people who dismiss the pacts signed between Japan, Germany and Italy to cautify the fact that they explicitly saw communism as a threat, do so in ignorance. It's often argued that it was some kind of fake political front to justify their actions, but on close inspection that seems to absolutely not be the case. These people legitimately believed communism was an existential threat.
This is further evidenced in the years after WW2, where there were many more communist conflicts in other countries. Korea, Vietnam, Cuba, Cambodia, etc. If you put yourself in their shoes, simply imagining being any of these countries, would it be unreasonable to feel an existential threat? No. Just, flat out, logically, no.
So why did they end up invading all these other countries? What was that all about?
The communists love to control the resources and in terms of a total global communist revolution, you've heard things like domino theory and you could understand it in numerous ways. One is that, if you expand to control a tipping point of resources, then you can leverage those resources to dominate the rest of the world and enforce your revolution.
Japan and Germany wanted to route out communism in other countries, but they also wanted to leverage the resources. Germany working with Russia to take Poland was largely strategic, not a sign of actual good faith towards Russia. Both Japan and Germany explicitly intended as their end goal, to conquer Russia and destroy Comintern.
This is part of why Stalin dismantled the Comintern, to deflate Japanese and Germany aims while simultaneously fostering military support from the allies.
Another critical point to support my argument, is that even if you don't think communism was the primary issue, why the heck would Japan and Germany join forces, causing it to become a World War? You could certainly argue that it doesn't become a World War until that happens. After all, people often make the mistake of saying the war didn't even start until something random in Europe happened and they can never ever convincingly explain how that caused the war to spin out of control. It makes no sense, because it is BS.
The war was already raging in the Pacific long before anything began in Europe. So why were the things in the Pacific happening? The thing that unifies both of these conflicts is communism.
People often deflect and just say oh Hitler was a racist and it was just this and that. They never answer the question: so what about Japan?
If they were fascist, what is a fascist? Many things, but most fundamentally they are a reaction to the communist threat. Communism is underpinned by a philosophy that all action is social action, so every person must be an activist. This puts society out of order rapidly, because anyone not involved gets overrun if it gains traction.
So fascists develop psychological counter-strategies to communism. That's why the Nazi flag was red. That's why they emphasize race instead of class, to unify people rather than divide them. That's why they uplift beautiful art and collected precious artifacts that communists hate and try to destroy. Everything was an intentional counter-strategy to communist revolution. It's easy to look back on it and say it looks insane, because it is and it is patterned as the inverse of communist revolution which is also itself insane. They wanted to immunize their country as a cultural powerhouse to fend off communism for all time.
And if the revolution was going to take over sufficient resources to steamroll other countries, then Japan and Germany were reasoning that they would need to expand to counter it.
Comintern wanting total global communism was logically inept and wrong for them to do. Germany and Japan going nuts and killing a ton of people was wrong for them to do.
It wouldn't have happened if the communists had not created a global existential threat. Remember too, this is before the internet, before pervasive communications and such. People still largely got their news from word of mouth, newspapers and radio so I'm sure there was plenty of miscalculation to go around, but the slow verifiable things were undeniable and that's what they were reacting to.
The communists have been threatening to start World War 3 and that is also what the Trump administration is reacting to today. Between Cuba, Venezuela and Iran, both Russia and China have lost essential partners in rapid succession. We've been helping Ukraine target Russian oil infrastructure which has dual purpose, since it both weakens Russia and also demonstrates to China that not only is their Venezuelan and Iranian oil not secure, but not even the oil they get from Russia is reliable. China built the largest strategic oil reserve in the world which is something like double the rest of the entire world combined and they were going to use it to sanction proof themselves in the case of engaging with Taiwan. Now they are drawing it down, which reduces the chance of WW3.