The numbers of rounds carried in WWII tanks reflected two things - the smaller caliber of the main gun and also the many different types of rounds available for different applications. Tanks carried HE, armour-piercing, smoke/WP, canister... you get the idea. A tank had many more general uses, in many respects, than a tank has in more recent years. Remember that doctrine wasn't necessarily about tank taking on tanks, but providing support, and that was reflected in the mix.So not enough ammo and you become a defenceless target when it’s exhausted. Too much ammo and you reduce your survivability in the event of a hit.
What’s the “right” amount? How is the same problem dealt with today?
In more recent years, the numbers of rounds have fallen as calibres have increased and rounds had become more specialised; broadly, you might see AP (sabot), a general-purpose HE/HESH, smoke and training. More recently still, because of experience in sandy places, a broader spectrum of rounds has been developed to meet a wider range of needs, such as punching holes in compound walls and killing whomever is inside.
But, for comparison, a 75mm-equipped Sherman would carry 90-104 rounds, according to a quick Google. That dropped to 71 on a 76mm-equipped M4. For comparison a modern M1 with a 120mm gun carries 40 rounds.
The actual numbers of rounds carried in WWII was driven by a number of things. Among them was the desire to always have 'enough', and that was influenced by the reliability or otherwise of the logistics chain. Speak to Africa Korps tankers on that one.
As noted, a lot of casualties were down to poor crew practice - 'poor' being a mix of the exigencies and realities (worries about the supply chain) and discipline (packing the home comforts or not being scrupulously clean). In terms of the latter, note that in recent conflicts cleaning out vehicles came back to the fore. Modellers might like to show lots of spent brass on the floors of APCs but in an IED-rich environment all of that, plus gravel etc., becomes a liability.
Wet stowage and stowage below the turret ring were developments that the Allies brought in. That persists in the CR2 to the day and was the sticking-point in terms of upgrading the main armament. Other 120mm-equipped MBTs which use a one-piece round have them partitioned off in the bustle. If the ammunition is hit and cooks off, the crew are still protected within the turret/hull. Getting rounds into the bustle became a favoured way of getting a kill amongst insurgents - a tank out of the battle is a tank out of the battle.
Once the realities of what was going on were identified, casualty rates dropped significantly. For reading, the following is borrowed from Wikipedia. Note the figures for wet-stowage M4s:
Research for tank casualties in Normandy from 6 June to 10 July 1944 conducted by the British No. 2 Operational Research concluded that, from a sample of 40 Sherman tanks, 33 tanks burned (82 percent) and 7 tanks remained unburned following an average of 1.89 penetrations. In comparison, from a sample of 5 Panzer IV's, 4 tanks burned (80 percent) and 1 tank remained unburned, following an average of 1.5 penetrations. The Panther tank burned 14 times (63 percent) from a sample of 22 tanks and following 3.24 penetrations, while the Tiger burned 4 times (80 percent) out of a sample of 5 tanks following 3.25 penetrations. John Buckley, using a case study of the British 8th and 29th Armoured Brigades, found that of their 166 Shermans knocked out in combat during the Normandy campaign, 94 (56.6 percent) burned out. Buckley also notes that an American survey carried out concluded that 65% of tanks burned out after being penetrated. United States Army research proved that the major reason for this was the stowage of main gun ammunition in the vulnerable sponsons above the tracks. A U.S. Army study in 1945 concluded that only 10–15 percent of wet stowage Shermans burned when penetrated, compared to 60–80 percent of the older dry-stowage Shermans.