I have seen several videos claiming that both Germany’s war on Russia and Japan’s war on the US were in a strong sense unwinnable. These often present their evidence using data (e.g. manufacturing data) that at least appears to have been public at the time of or before the wars (here talking fronts of WWII, of course). This being said, why would any of the axis powers have got involved in these wars in the first place? What were the factors that lead to either of Japan or Germany being convinced it had any hope in its respective wars?
I cannot profess to know anywhere near as much about the Japanese position so will restrict myself to the outlook of Hitler and Nazi Germany.
In Hitler's so-called 'Second Book', he delineated his assumption that all of history is "the course of a people's struggle for existence", a struggle that focused on economic resources and the ability to access them. In this, his worldview had been forged in his experience of Germany's defeat in the First World War, a large part of which he considered to be a result of economic overdependence on the global economy in the face of total war. As such, warfare and a people's fight for survival were principal elements of Nazi thinking. Clausewitz had been right, Hitler announced after watching German summer manoeuvres in 1938: "War is the father of all things; every generation has to go into war once." Demonstrating that very little had changed in a decade, he wrote, "What is ultimately decisive in the life of a people is the will to self-preservation. [Warfare is] quite in keeping with nature" ten years earlier.
The ideological position of warfare in Nazi Germany is therefore crucial to consider when thinking about why it embarked on a war that seems, from our position of hindsight, doomed to failure. From the very beginning, Hitler considered Germany to be at odds with communism and Judaism, and the Soviet Union was considered by the Nazis to be an unholy amalgamation of both. If the "conglomeration of animals" [ie the Russians] ever found its way to Europe, feared Goebbels, "the human mind cannot possibly imagine what it would mean." Political realities allowed for temporary collaboration with the Soviets, such as the infamous Molotov-Ribbentrop Pact, but neither side was under any illusions about the long-term prospects of such deals, and by June 1940 German military command was drawing up plans for operations in the Baltic states and the Ukraine to remind the advancing Soviets who was the big dog in Europe. By 29th July, Hitler's chief of operation, Alfred Jobl, announced to his colleagues that the Führer had decided to deal with the Soviets "once and for all". War with the Soviet Union was rationalised in military and political terms: it would allow for the complete domination of continental Europe, which would in turn allow for better prosecution of the war against Britain and the United States; Soviet resources would further that same agenda and allow for autarky in the struggle with the West.
Some of it was true, some may have even been believed, but the real driver was always the completion of Hitler's fantasy of a revolutionary war against communism and its Jewish allies. In the autumn of 1939, Hitler was already confiding that the war against France and her allies was a sideshow, something "to free his back for the confrontation with Bolshevism". He needed a quick victory there so the army could be turned to the east- Bolshevism remained, he told Goebbels in August 1940, "enemy number one", the war against it to be a "struggle of two opposing world views".
Ideological blinders and preconceptions ensured that most believed the campaign would go without much trouble. It should come as no surprise to learn that Hitler and Nazi leadership expected the Soviets to crumble ("The Führer estimates that the operation will take four months. I reckon on fewer. Bolshevism will collapse like a pack of cards", recorded Goebbels in his diary in 1941), but senior Wehrmacht command elements agreed: General Blumentritt had such a low opinion of Soviet officers that he speculated that victory could come after a fortnight of fighting. By May 1941 he had revised this estimate down to less than two weeks given that the Germans were facing 'ill-educated, half-Asiatic fighters." In general, senior officers shared Nazi anti-Slav, anti-Communist and anti-Semitic prejudices, and the only concern was with the effect on discipline the methods required for the coming war of extermination might have. Any doubts from those who had read their histories of Napoleon's invasion or fought in Russia during the First World War were quashed by the Wehrmacht's triumphant record in Poland, Denmark, Norway, the Low Countries, France and the Balkans. Enlisted men shared these triumphal sentiments. One soldier in a mountain division wrote, "we are off... against our mortal enemy, Bolshevism... I am very optimistic... And I believe that if we can take all the land and raw materials up to the Urals, then Europe can feed itself and the war at sea can last as long as it will." An NCO in an SS division proved even more positive: "My conviction is that the destruction of Russia will take no longer than that of France, and then my assumption of getting leave in August will still be correct."
These assumptions were not proven false by the initial stages of the campaign. By September, incredible gains had been made: Axis forces were driving towards Moscow, having taken Kiev, surrounded Leningrad, killed almost a quarter of a million Soviet troops, taken more than two million prisoners and destroyed nine-tenths of Soviet armour. Faced with this kind of staggering success, it is hardly surprising that Hitler returned to Berlin on 4th October, assured that his conviction had been vindicated, where he announced to a cheering crowd in the Berlin Sportpalast that the Soviet Union had been utterly defeated, and "would never rise again."
In conclusion, Nazi ideology and existing prejudices ensured that the Germans would at some point attempt to confront the Soviets, in spite of what we recognise today as considerable inferiority in economic war-making potential. While the invasion was initially justified in strategic and political terms, Hitler's anti-Bolshevik rhetoric and beliefs propelled the collision with Stalin's Russia, and, in the beginning at least, it looked very much like he had been correct to begin this titanic conflict.
Sources: Overy R., The Dictators: Hitler's Germany, Stalin's Russia (Penguin, 2005) Beevor A., The Second World War (Weidenfeld & Nicolson, 2012)
Why Germany attacked the Soviet Union in 1941: Hitler had a long-standing ideological desire, spelled out in Mein Kampf, to destroy the nerve-center of “Judeo-Bolshevism” and conquer “living space” for the German people in the rich lands of Soviet Russia, which would sustain a pan-German continental empire that could fight other continental powers over the long run (most notably the US). The immediate timing was dictated by short-term military/strategic considerations: defeating Russia would deprive Britain of a major potential ally and destroy any remaining hope of continuing the war, and also secure Germany’s eastern flank before the inevitable entry of the United States into the war in the near future. If the destruction of Russia gave Japan a free hand to pursue its ambitions in the Pacific and tie down the US there (foreclosing American entry in the European theatre of war), all the better. Kershaw in the second part of his Hitler biography goes into detail about Hitler's strategic calculus in the run-up to Barbarossa.
Why the eastern war actually was winnable for Germany: Richard Overy in Why the Allies Won pretty thoroughly debunks the notion of a Soviet resource/production advantage dooming Germany from the start. The Germans during Barbarossa overran the agricultural and industrial heartland of the Soviet Union: grain and meat supplies were reduced by half by 1942, electrical capacity by 40%; iron ore, coal, and steel by 75%. By 1943, the Germans were producing 30 million tons of steel and 340 million tons of coal to the Soviets' 8 million tons and 90 million tons respectively. So the resource advantage, if anything, ran the other way. The difference was how those resources were used. Russia relied on efficient mass production techniques, using only two main tank models and five aircraft models, to churn out weapons (more in 1942 than 1941, remarkably). The Germans, meanwhile, were suspicious of mass production methods because they thought it sacrificed quality for quantity. They had 425 aircraft models, 150 different types of motorcycle, and 2,000 different types of vehicles in all in the initial invasion. German custom-built weapons were indeed things of beauty, with Allied officers marveling at the sophistication of captured German equipment. But the Germans just didn't produce enough of them. German aircraft production barely budged in its first two years of the war, from 8,000 planes produced in 1939 to 11,000 in 1941. The Soviets more than doubled theirs between 1941 and 1943, from ~16,000 to ~35,000. By the time Albert Speer streamlined German war production in 1943 and put Germany on a full war-time footing, the tide of war had already turned against Germany.
Sources:
Fateful Choices: Ten Decisions that Changed the World, 1940-1941 by Ian Kershaw
Hitler 1936-1945: Nemesis by Ian Kershaw
Why the Allies Won by Richard Overy