As others have noted, the reasonable starting point is stacking. If you need to stack lots of bread for significant periods of time, you want a shape that does not waste space. So the cross-section would be a triangle, a rectangle, or a hexagon.
The problem is that pretty much all storage spaces where we would stack things are rectangular and will store rectangular bread more efficiently. Only advantage a hex has over a square is that it has less crust per volume.
So we need some reason to minimize the amount of crust. The easy solution is that the crust is actually inedible. Considering that this is bread that is stored long enough that stacking efficiency is a major issue, the bread itself is probably completely dry, extremely dense, and hard enough that you need to soak it for a while before you can eat it. More a biscuit than bread. For the crust to be inedible in comparison, it must be toxic. As in, rats gnaw at it and die.
As noted in a comment, a toxic crust would also be an added cost and would give an added reason to minimize the surface area. So if you use such crust a hexagonal bread will be better than a rectangular.
This actually makes sense. Any bread stored long enough that stacking efficiency matters would have to be protected from spoilage. It should be rat proof, insect proof, mould proof, and water proof. Being fireproof would be nice, but given the extreme dryness would be hard to achieve.
So after it has been baked in a metallic mould, it is lacquered with a lacquer that is either toxic enough to kill rats itself or has some arsenic added to it. Once the lacquer dries it forms a hard insect and water proof surface. The toxicity gives protection from rats and other vermin. The smooth hardened surface also makes storage slightly easier. Since the bread itself is very dense the poison will not penetrate beyond the surface layer.
This kind of bread should store for a very long time. And you would not need to worry about keeping the storage dry and free of vermin. This is important because it combines with high stacking efficiency to make long term storage cheap enough to be practical.
Then after you are out of everything that is actually edible, you go to the farthest corner of the basement, pick some of these hexagonal rods your grand father stacked there, cut off the brightly coloured (probably red/ochre) crust with a saw, then use a clean saw to cut the rod into thin slices, boil some water, soak the slices in the water, eat the slices once they have softened enough, and pray to all Gods you can remember that you will not die.
You could call this the "red bread of last resort", I guess. Although I imagine it could be some sort of gourmet delicacy, if it was spiced in some way. Since it can be stored for a long time, the taste could mature over time. A bread equivalent of fine wines or cheese.
I thought some about what possible disaster would make such emergency food make sense and by coincidence saw a video about medieval castles. Sieges were prolonged affairs and properly designed castles could hold out until the defenders run out of supplies. The amount of food stored when the siege starts would then be of crucial importance. This would give real value to food that can be stored for long periods of time.
Castles were also fairly expensive to build. This means that spending some extra money on making food store better might be practical and that food that stores efficiently would have real value because space was at premium inside castles.