One of the factors not mentioned previously was the relatively sad state of affairs within the American and Allied militaries. The Axis armies, particularly the German Army was very well trained, and very professional about what they were doing. The American and British armies needed time and experience to get to the point that the German Army was at in terms of expertise and leadership, etc.
Luckily the strength of the German Army was being absorbed and destroyed on the Eastern Front or it is very likely that the Allied march through Western Europe would have been far more difficult. But the Allies also quickly gained the experience and their unit leadership improved rapidly through campaigns in Northern Africa and Southern Europe and then Western Europe.
Indeed, the Axis powers flexed their muscle in the first portion of the war. This was especially true in the Pacific theatre. The Allied forces made a clear and conscious decision to ignore the Japanese threat in the Pacific. This allowed the Japanese to pretty much run unobstructed throughout South East Asia. The decision to ignore the Japanese at first was designed to ensure that the primary target of the war was Nazi aggression and Axis growth in Europe. This helped Japan immensely, even though it was Japan who struck the United States at Pearl Harbor. Given the Nazi presence throughout the European continent, they held the upper hand at the start of the conflict. This was accentuated by the fact that Russia and the Western powers were not necessarily on the same page at the start of the war. This changed once Eisenhower and the other generals conceived of the two front strategy, an approach that would drain Nazi/ Axis resources in fighting the war on two fronts. In doing so, the Axis powers had an advantage at the start of the war, but this would not last as the Allied forces would increase their own supremacy and dominance in Europe and then in the Pacific region.
In both theaters of the war, the Axis had the upper hand in the first couple of years of the war. In both theaters, really, the Axis was doing better than the allies until about the spring of 1943. This does not mean that they won all the battles, but it does mean that things were generally going their way.
The main reason for this, in my opinion, is that they were the aggressors and so they were prepared to fight. The Allied countries had been trying to avoid war so they had not built up their militaries so well. When the Axis attacked, they knew what they were doing and the Allies were generally not ready to fight. Because of this, the Axis won for a while. This would continue until the Allies became more ready to fight in terms of armies and in terms of materiel.