if you look at that image, you can actually see that the walrus's machinery takes up more then 1/3th of the hull length, while on the T212 it takes actually quite a lot less.
a. Diesel and battery technology has not changed that much since 1950.
wrong! when the walrus were build, there was very little of battery types not close to lead cells. right now we have lithium and all variants of it.
as for diesels, due to computer technology in managing the proces in the engine, designing the engine and material science advances diesel engines of the same power have gotten smaller and smaller over the years.
b. Cube of volume is very different from hull length. The difference in the amount of work space is astonishing.
you are talking to an shipbuilding engineer, why on earth did you think I did not know that? to be exact, when you scale a ship up, you can calculate the volume by scale factor ^3. however, due to the dimensions of torpedo's, the length is most important factor in this discussion.
c. More torpedo tubes eat more machinery space and that also involves more handling equipment in length run, which eats up more cubic work volume than supposed. (The cutaways of the Type 212 and Walrus illustrate this stark factor clearly.)
the handling equipment is mostly an small crane on a rail. you can make it much more, even auto loading, and that of course takes more space. it does not have to be so though.
d. Torpedoes include handling and ramming machinery behind the torpedo racks;
this machinery however, does not have to be much longer then the racks themselves. hell, it can even be shorter when the torpedo's are hand-loaded into the torpedo tubes with just a small crane.
all in all, the reason for the smaller torpedo storage on the 212 seems to be the battery bank underneath the torpedo tubes forward. at the cost of range or speed (due to modding hull shape for different weight) a designer can surely play a bit with that