A combination of gun design and ammunition. When it comes to armor penetration with WW2-era tank guns, velocity is a huge factor, and the Panther's gun and ammunition were designed to produce very high velocities. Remember that the caliber measurement of an artillery piece (or any gun, really) is only one piece of the puzzle, and that case volume, shell/bullet design, and barrel design (especially length) can result in a massive difference in the capabilities of a gun.
The Sherman's 75mm gun was primarily designed for firing high-explosive shells, and although the gun did have a reasonably effective armor-piercing shell, American armor doctrine of the time expected Tank Destroyers, not tanks, to be optimized for taking on enemy tanks. As such, velocity wasn't incredibly important (within reason), as the effectiveness of high-explosive shells depends more on shell volume than velocity. Shells had 350mm long cases, and with the L/40 (40-caliber-long) barrel of later models, that provided for a muzzle velocity with armor-piercing shells of about 2,000 feet per second.
Compare that to the Panther's 7.5 cm KwK 42. The KwK 42 had an L/70 barrel, providing more time for pressure to act on and accelerate the shell out of the barrel. Adding to this was the propellant - the 640mm cases of the armor-piercing shells fired by the Panther had significantly more volume for propellant. That combines with the longer barrel to produce higher pressures and a longer period in which these pressures accelerate the shell, producing a significantly higher muzzle velocity - a whopping 3,000 feet per second for Panzergranate 39/42 AP/HE shells, and up to 3,700 feet per second on Pzgr. 40/42 APCR shells.
So by using a significantly larger gun with more propellant for the shells, the Panther's L/70 could produce significantly higher velocities, and thus better armor-piercing potential, than the Sherman's L/40.
One aspect as to why was a difference in philosophy. American tank crews, and many ranking officers, saw no need to replace the 75mm on the Sherman. The HE was excellent and AP was good enough. Part of designing a tank gun is finding a balance between AP and HE. The more pressure you have in the barrel to accelerate an AP round the more likely it will be that something goes wrong with HE ammunition. This leads to lower HE filler in the rounds which is usually what a tank would fire more often. Another reason is that Ordinance would have a tendency to go mad scientist so it became policy that unless there was a need for something in the field requested by the units fighting or superior officers they couldnt really do much past blueprints. They did this to save money on building useless or poorly designed equipment. I remember reading that there were Shermans available for D-Day with 76mm but were left because the crews preferred the 75mm. One thing a lot of people miss is that the US was late not only to the war but the technology battle as well in some cases. The Sherman's upper plate was designed for stopping 50mm rounds. It wasnt until later into the war that it really became an issue as more weapon systems could kill it. Also the death trap rep the Sherman had wasnt really true either. It was figured up post war the British tanks had higher death rates. But many factors played into that.
The Germans on the other hand were more willing to make the sacrifice of their HE rounds for better AP penetration. This mentality could very well from being how many tanks they had to fight and the quality of some of the models. The Allies didnt have to fight nearly the same numbers so this could have played a role into the mentality. Just some more to add to the other great comments