These countries had real world evidence of it happening and back then times were hard. You had starvation, unemployment, mistreatment and really societies were still trying to find the balance in an industrializing age. This was ripe territory for the spread of Marxism and it was adapted differently to a country depending on what the main complaints were.
Simply look at the spread of communism to other countries even after World War 2. You need to pay close attention to that, because it's the same fear other countries had before WW2. This was a very real issue and simply falling back on some propagandistic argument that the role of communism was overblown because of X, Y and Z, ignores all the reasons the communist threat wasn't overblown.
I think people forget that back then, death was normal and constant. People were dying all the time from all manner of both horrific and normal things. Most countries wanted to achieve some kind of stability and countries invading other countries was much more common in the recent history to them in a way that threatened them or in other words was normalized.
If the US had relative stability, England had relative stability and Russia had relative stability, countries like Japan and Germany did not. The great depression and communism both combined with the trade protectionism to create an internal existential threat. Suddenly you had mass hunger and unemployment. Yes they wanted to expand, yes they wanted more room for their people, but a strong factor that drove it to be existential was communism. Several of these other countries had already appeased communism, like France.
Germany and the US had already been fighting against communism in Spain and China, so this was going on long before the European side of the war started and it was a demonstrated actual acted on concern with evidenced history. If communism was going to expand, then if Japan and Germany wanted to survive communism or generally an expanded Russia. Like, think back then. You had Britain which had its empire. Now imagine a Russia that had an expansive communist empire.
Germany and Japan both had a rough history with Russia trying to take their territory. If they were going to be able to survive in an environment with an expanded Russia with vast communist acquired resources in an industrializing world, they would have to expand and establish control of resources of their own.
I'm not saying that it was right or good or that Japan and Germany don't take any blame and they were simply defending themselves, because that's not the case. Everybody made mistakes, but back then miscalculations were common and life was harsh. We take the comfy relatively peaceful life today for granted, but life was an everyday natural disaster back then by comparison to today. If you look at how Japan and Germany both prioritized their threats, communism was at the very top. It was real, they acted on it and as humans they acted in ways that demonstrate it was their highest priority.
Many European countries had official communist political parties and in the stable countries they didn't have much sway, but in other countries suffering from economic ruin from every direction, communist parties were gaining a lot of traction. The timing for why Hitler was appointed was explicitly because the communist party was gaining too much influence and reached the point of being an existential threat.
Make sure that you know one specific thing. Communism was basically known for dissolving countries from the inside, destroying their culture, their history and their identity. This is why it's more than simply worker activism, it's an existential threat to your civilizational existence. Japan and Germany both had strong cultures with a lot to lose.
There is no version of history where the communists are innocent, kind and good and there is no version of history where Japan and Germany are innocent, kind and good. That said, communism was actual evil even if on its surface it aimed to help workers. They legitimized and normalized horrific murder and assassination in all kinds of countries.
Part of the economic disaster that hit Japan and Germany was because of trade protectionism that went to extremes, because countries were protecting their local trade out of fear of communist revolution and they relied more on external trade for their needs. Without vast natural resources to leverage they couldn't sufficiently provide for their people without open trade which was closing down.