It can be argued that there were in fact 2 major wars that occurred from 1939-1945. The first, a European war, lasted from September 1st, 1939 until September 30, 1941 (i.e. 2 years), which Germany decisively won. The 2nd war, which started when Hitler declared war on the USA they obviously lost, at least in the short-term. The other thing to consider is who won the war in the long term? Did Germany really lose long-term?
Anyway, the reason why Germany didn't 'win WW2' was simply because they failed to achieve a decisive victory over the Red Army in the Battle of Moscow, which started on September 30th, 1941. Had they done so it wouldn't have mattered one bit whether Hitler declared war on the USA or not. if Hitler knocks Stalin out of the war everything changes.
In fact, let's narrow it down further. There is much contention over this but the reason that Germany lost WW2 might be because of the 'Lötzen