The internal pressure in the can is resisted by the walls in two different ways: (1) by stretching the wall and (2) by bending it.
A typical beverage is made of material that is as thin as possible (to save weight and cost), and therefore its stiffness in bending is very small compared with the stretching. The ratio of the two stiffness values can be of the order of 1,000,000:1 or even higher. (This huge difference in stiffness explains why it is very easy to crush an empty can by bending it!)
To resist the internal pressure by stretching, the tension in the wall of the can varies like $P\kappa$, where $P$ is the (almost constant) internal pressure and $\kappa$ is the radius of curvature of the can at any point. For a sphere, the radius of curvature is the same everywhere, and therefore the stress is the same everywhere.
If the can has "flat" surfaces, like a cuboid, the radius of curvature over the flat sections is infinite and the result given above would mean the stress was "infinite". In real life, the internal pressure causes the "flat" surface to bulge outwards and thus become curved, but the radius of curvature is still very large compared with a sphere.
This also explains why cans and plastic drink bottles don't have a flat base. To reduce the stress, it doesn't matter whether the base is curved outwards or inwards relative to a flat surface, but curving it "inwards" means the can or bottle can stand on a flat surface without toppling over. (That also appeals to the marketing department, because the visible "size of the can" is bigger than the internal volume of liquid you are buying!)
The transition from the cylindrical body of the can to the inwards-curved base increases the stress around the edge of the base, but for a beverage can the ability to stand in a stable position is more important than the higher stress. Compare that with a compressed gas cylinder, which has a much higher internal pressure but doesn't need to stand unsupported, and where the base (usually a hemisphere) curves "outwards".
Since the top of the can needs to be flat for practical reasons, the top has to be made of thicker material than the rest of the can - though a small amount of "bulging upwards" at the top doesn't matter too much. As with the base, high pressure gas cylinders have hemispherical tops not flat ones, to reduce the stress.