"Because Hitler", and his enablers, but even he had his reasons, if misguided. Hitler still believed Germany could win the war. And if they lost the Soviets would have their revenge. A strange mix of optimism and fatalism drove German strategic decisions.
Optimism and Fatalism drives Desperation and Delusion
A realistic assessment of the German position would have had them pulling back and consolidating their forces sometime in 1943 while they still had the strength to defend and Allied air power and fuel supply would still allow them to move. Then from their defenses they could negotiate a peace.
Instead they threw away their strength on desperate offensives. The biggest examples are Kursk in Summer 1943, the Battle of the Bulge in Winter 1944, and the very expensive and strategically dubious Vengeance Weapons.
Right up until the end, the thinking was that Germany could still win the war. Somehow. As increasingly mad as it was, that was the presumption upon which decisions were being made. And it's the only way they make sense.
...because if they don't, the Soviets will have their revenge. This grim reality drove increasingly desperate measures. Not just Germany can win, but Germany must win.
Increasingly overstretched and desperate to stop the Soviets, Germany spiraled into deeper and deeper delusions. This created a tendency to ever increasingly embrace intelligence that made Germany look stronger and the enemy look weaker. They accepted plans with increasingly long odds, tighter and more unrealistic timetables, and more and more pieces which have to go off perfectly for the plan to succeed. The Battle of the Bulge, even if it went off perfectly, was unlikely to have resulted in the Western Allies suing for peace. By 1945, Hitler is ordering divisions and armies around which were skeletons of their former selves.
The Wehrmacht of 1944 and 1945 was not the Wehrmacht of 1941. They had been bled white. Fuel was low. Supply lines were stretched. Pilots and soldiers were inexperienced. Mobile divisions were using assault guns in place of tanks. Their quality had plummeted.
Some units were so unreliable they were formed into bodenständig, "static units". These units had large numbers of elderly and invalid, POWs, and conscripts from outside Germany. Much of their heavy weapons were from captured stockpiles. They had little transportation. These units were most useful to defend the fortified positions, and not much else.
Resources and Holding the Axis Together
Germany was dependent on occupied, neutral, and allied countries for resources. Coal, iron, oil, manpower, food, vehicles, and arms. Without these territories, the German war machine would slow even further. In order for Germany to win they had to hold onto these territories and keep the supply lines open. This might mean keeping a garrison to prevent an Allied invasion, keeping trade routes open, or simply browbeating allies to stay in the war.
Had they pulled back to Germany all these resources would have been lost, and many of those former Axis partners would be turned against them, as we'll see in Romania. If Germany were to win, they must keep their partners and occupied countries in the fight.
With this in mind we can look at individual positions and strategies and how they fit into this strategic mindset.
Why Defeat the Western Allies First?
Rationally, the Germans should have been throwing everything they had against the Soviets while practically welcoming the Western Allies in as more safe occupiers. Paradoxically, relative to the size of the forces involved, the Germans put more emphasis on defeating the numerically smaller Western Allied armies, with their last gamble being in the West, not the East.
This is because of the axiom that Germany can still win the war. The classic strategic conundrum for Germany is, being right in the middle of Europe, how do you win a two front war? The obvious solution is to not get into one in the first place, but they blew that.
The classic German solution is to knock out one opponent and then deal with the other. This was the goal of the Schlieffen Plan in WWI, knock out France before Russia could mobilize. They failed. They later succeeded in forcing a peace in the east and sending their troops west, but too late. Instead bled themselves out in their spring 1918 offensive.
In WW2 they succeeded in knocking out France, but failed to finish the job with Britain, and then foolishly declared war on the United States while still fighting the Soviets.
Now in late 1944 they were at it again. They couldn't defeat the Soviets while holding off the Western Allies. Maybe if they hit the much smaller Western Allied armies hard enough they'd negotiate a separate peace, then the Germans could shift all their forces to the east.
Denmark, sharing a border with Germany, is a possible Allied invasion route. It must be defended else the Allies could leapfrog all of Western Europe.
Abandoning Denmark means losing control of the vital shipping lanes between Scandinavia, the Baltic, and the Atlantic. The German surface navy was very active in the Baltic providing fire support and evacuation. Submarines had to transition between German Baltic ports and the Atlantic. Supplies, primarily iron ore from Norway and neutral Sweden, had to pass through Danish waters.
Norway was a vital source of iron and other minerals desperately needed by Germany to produce the high quality steel necessary for machines of war. The Allies had their eyes on Norway since the start of the war, and continued to convince the Germans an Allied invasion was imminent.
Italy was the first Axis partner to fall. Germany bullied Italy to stay in the war and continue to provide men and material to the Axis.
In addition to resources, Italy, consisting of two narrow strips split by a rough mountain range, was some of the best defensive ground the Germans could have hoped for. The more Allied resources were ground up in Italy, the less they could use against Germany.
By 1945 the Axis had been pushed back to the flat country of the rich Po Valley. The next good defensive line was the Alps, which meant losing all of the industrial and agricultural capacity of Italy.
Romania was a major source of oil, food, and equipment for Germany. As the war in the east turned decidedly against the Axis, and as Germany treated Romania poorly, they became more and more reluctant partners.
In late summer 1944, with their defenses crumbling, King Michael overthrew the government and declared for the Allies. This threw the Axis lines into disarray with some Romanian units fighting for Germany, some against. Soon the Romanian army had joined the Soviets in pushing the Germans out of Romania and were pursuing.
This is the outcome the Germans were trying to prevent; loss of resources compounded by having their allies turning on them.
The next Axis partner on the chopping block was Hungary. Like Romania, an increasingly reluctant Axis partner. And like Romania, one of the last sources of oil for the Germans.
Hungary began negotiating for a separate peace and was invaded by Germany in March 1944 to keep them in the war. When the Soviets arrived in the fall, again Germany intervened to keep Hungary in the war. So important were the Hungarian oil fields that Germany conducted its last major offensive in an attempt to hold on to them.
And so on. Axis territory lost meant lost resources and manpower, so it had to be defended. Axis partners must be kept in the war for both their resources, and to prevent them from switching sides. All this is predicated on the increasing delusion that Germany can win.