This article from DataGenetics explores the reasoning behind can and food storage manufacturing:
f the goal was to purely maximize the volume of food that could be stored in a container, the result would be a spherical can. A sphere is the shape with the minimum surface area to volume ratio. It could contain the most amount of food for the least amount of can material. However, it would be totally impractical! It would not stay still on a shelf, making display and storage hard. How would you hold it? How would you open it? How could you manufacturer and fill it? When stored in packing boxes, even with hexagonal close packing there would be unused gaps in the storage boxes.
Clearly optimizing purely based on minimizing the material needed for an individual can is not optimal.
If we wanted to use a shape that packed perfectly efficiently, we’d use some kind of cuboid. These would sit and stack nicely on shelves too. They’d be easier to manufacture than spheres, but the edges would be stress points. You occasionally seen cuboid-like containers (corned-beef, spam and sardines are the first that come to mind). Rather than sharp edges, these have filleted (rounded) edges to reduce stress concentrations and to make them easier to manufacture.