For most of the war, the allied powers kept mass producing smaller medium tanks like the Sherman and T-34. It wasn't until the end of the war when they started building heavier tanks like the Pershing, IS-2, and Centurion. Why did Germany not take note of this? I understand that nations like Italy and and Japan just didn't have the infrastructure to build heavier tanks; or many tanks at all, but Germany somewhat did. Like they could build huge monsters like the Tiger 1 and 2. They built a few Jagdtigers and Jagdpanthers. Heck, they even built 2 Maus's! Why would they not focus on building lighter, more practical vehicles like the Panzer 4, the Panther, and Stug assault guns? Like did they not notice that the allies weren't building anything heavy?
I'm going to answer your question in reverse order, starting with "Why would they not focus on building lighter, more practical vehicles like the Panzer 4, the Panther, and Stug assault guns? "
The Pz.Kpfw.IV design came about in 1936. This was an 18 ton tank. By 1945 it had grown to 25 tons. The chassis designed almost a decade earlier was at its limit. It had a longer 75 mm gun, but without any changes to the turret ring or significant changes to the turret, it needed a huge spring to keep it balanced, plus the turret itself was out of balance. It was not possible to put in a larger gun or change the turret without triggering a large set of changes throughout the whole tank. The armour was in a similar state. The front hull armour was 80 mm thick by then, but the front turret armour was only 50 mm thick, since the chassis could not take any more weight. We can pretty easily see what would happen if the Pz.Kpfw.IV got any heavier. The Panzer IV/70 (V) tank destroyer weighed 27 tons, which triggered a cascade of failing running gear and suspension elements. By 1945 it was not possible to make the Pz.Kpfw.IV any heavier and there was nothing left to strip out to make it lighter.
What about the Pz.Kpfw.III? The problem arose when trying to put anything bigger than a 5 cm KwK L/60 or 7.5 cm KwK L/24 in it. Sure, the 7.5 cm KwK L/43 could fit as the Pz.Bfw.IV Ausf.K proved, but the Pz.Kpfw.IV was also right there and could take the new gun without modifications. While we don't know what this chassis's weight limit would have been, Soviet trials of the SU-76(I) (an SPG built on captured Pz.Kpfw.III and StuG chassis) showed that the suspension and running gear began to show increased wear and more frequent failures at a weight of just 22.5 tons. It's possible that the Germans could have squeezed out another ton or two out of the chassis with design changes, but it's unlikely that it would have surpassed the Pz.Kpfw.IV chassis.
Now, what about the giants? Germany actually had a very gradual plan of action for upping the weight of its tanks. Approaching the end of 1941 you had some medium tanks in the 20 ton weight class and heavy tanks in the 30 ton class. In preparation for the invasion of the USSR, heavier projects popped up such as the VK 45.01 tank in the 45 ton weight class (don't let the 45 fool you, it was known from the start that the weight would be more than 50 tons). Since little was known about the USSR's tanks, the requirements kept rising as rumours came in. The armour (80 mm in the front, 60 on the sides) was suddenly not enough, and so it became 100 in the front, 80 on the sides. The 88 mm gun with the ballistics of the Flak 36 was not enough, and so a longer gun had to be installed (although its installation required a new turret which only ever went on the Tiger II), and so on and so forth until the tank hit a weight of 60 tons by the time it reached production. The Tiger was suffering from its weight as it is, and work on a whole new chassis began before the tank was even mass produced.
The Tiger II also grew during development as requirements gradually rose. The upper front plate was initially 100 mm thick, just like the turret (incorrectly known as the "prototype turret" or "Porsche turret" used on early Tiger II tanks) but grew to 150 mm. The tank's second turret had 180 mm of front armour, thus resulting in additional weight.
The Panther went through a similar development cycle. Introduction to the T-34 tank inspired the Germans to make their own medium tanks with thick sloped armour, so the 20-tonners died before they were truly born. The 30-ton class replacement for the Pz.Kpfw.III and IV was initially estimated to weigh 32.5 tons, but the weight limit was quickly raised to 36 tons. The thickness of the required front armour went up from 40 to 60 to 80 mm, the front of the turret went from 80 mm to 100. All of these changes were followed by weight gains, and so a nominally 32 ton tank weighed 45 tons when it went into production.
Just like in modern engineering, requirements for armoured vehicles gradually drifted. In an attempt to "keep up with the Joneses" vehicles on the drawing board were modified to stretch them past their initial constraints, which had considerable side effects. Note that while the Pz.Kpfw.III and IV gained about 10 tons of weight during their service life due to significant upgrades in firepower and armour, neither the Panther, Tiger, nor King Tiger could be upgraded as they expended any room for upgrades and then some while on the drawing board. The very reasonable 32 ton medium and 50 ton heavy (just like what the Allies ended up with by the end of the war) came out of the factories bloated and with no room to grow.
To finish, I would like to contrast this development style with what the Soviets did. Just like the Germans, they began to work on a new medium tank to reflect the new realities of war: the T-43. Work on the 33 ton tank began in the summer of 1942, an improved prototype built in the summer of 1943 already weighed 34 tons. In the fall, requirements were raised: the new tank had to have an 85 mm gun and 90 mm thick front armour. Calculations showed that the armour alone would up the tank's weight by 680 kg, which was considered unacceptable. A difficult decision was made to walk away from the tank that engineers spent a year and a half on and start again. The resulting T-44 weighed only 30 tons, but had comparable protection and firepower to the 45 ton IS-1 heavy tank. However, this ruthless adherence to the weight limit and the resulting delay was one of the factors that kept the T-44 out of the war. Even though it was an incredible vehicle for its time and mass production began in 1944, it never saw battle.
Sources and further reading:
In concurrence with BobTheAverage's comment, the answer above didn't really respond directly to the question and the motivations behind Germany's decision to build heavy tanks. I'd like to answer OP's question directly from a broader strategic perspective based on new research by the Nazi historian Adam Tooze, most of this information is from his book The Wages of Destruction which is an economic analysis of the Nazi regime with an eye for its broader geo-political considerations.
So first it’s important to stress that Germany was at a huge economic disadvantage from the onset of the war, even prior to it, and all the way until it’s very end. The idea that Germany was an advanced technocratic nation was a myth largely influenced by their success in the blitzkrieg to absolve the incompetency of French and British commanders. Germany was actually an incredibly poor country and they only partially modernized militarily in the 1930s.
Economic and material considerations were consistently at the forefront of Nazi strategic and military planning. They knew that their economy was incapable of a protracted war with the allied powers—this was the nightmare of WW1. Basically, from 1943 onwards, when the Nazis capitulated at Stalingrad and pretty much exhausted large parts of its first line of draftees, Nazi leadership knew that it needed a swift and decisive victory in the East to stop the Russians before the US joined the war. They were conscious of the fact that the longer the war drew into a deadlock, it would drain their resources in the exact same fashion that led to their defeat in WWI.
As desperation for a quick victory in the eastern war increased, the Nazis began turning to “miracle weapons” that would change the tide of the war with a single blow. This is why 1943 was the year when plans for the V2 rocket and the atomic bomb were approved, despite being seen as too outlandish in previous years—the regime was desperate for a fast technological solution out of the strategic nightmare that they were in sandwiched between the two greatest industrial powers of the world. The Maus 2, Uboat mark 11, and jets were all included on this list of miracle weapons that supposedly had the ability to win the war in a single decisive blow.
Although the Tiger 1 and 2 were by no means outlandish miracle weapons in this sense, they served the same strategic purpose, and were still produced after 1943 for the same reason: to break the deadlock in the East and provide the Nazis with a decisive victory that would put them back in the running to win the war in the long-term. The T-34 was superior to the Panzer 3 and 4, and they could be produced in far far greater quantities becsuse of the Soviet industrial boom in the Urals. And Nazi leadership knew this. So naturally, their logic was “quality over quantity,” they knew they couldn’t outproduce the Russians much less the Allies in medium tanks, hence why they were putting increasing stock into the production of Tiger 1s and 2s which were supposed to make up for the deficit in material resources by completely outclassing the medium tanks fielded by the Allies.
In short, they were at huge economic disadvantages, were conscious of it, and saw quality over quantity as the “miracle” solution to winning the war against vastly superior powers in terms of manpower, resources, and industry, hence why they were increasingly producing heavy tanks of the tiger 1 and 2 class even though the Allies didn’t field them until late in the war.