That, however, doesn't last forever. In the conditions of the 18th century or whatever, microorganisms will get into the beer after mashing/boiling, so the heat treatment only helps for a while. The fermentation really does protect the beer afterwards, but it's a combination of low pH, alcohol, low oxygen, little nutrients, CO2, etc. Hops also help against gram-positive bacteria.
In continental Europe they were popular from roughly ~1000 onwards (see Behre 1999), in England from roughly 1500 onwards. In African and South American farmhouse brewing they're still not used. So it's a pretty complicated picture.
As the comment made clear, hops are only one component of what makes beer safe, though. Storable, safe beer for travel is documented already in Ancient Egypt.
There may be other reasons to prefer beer where the alcohol is relevant of course, just not for freshness. And freshness could absolutely have been relevant in the choice of drinks to load, together with low cost and acceptance in general.
> There may be other reasons to prefer beer where the alcohol is relevant of course
I imagine these are largely the same reasons people drink beer today. Spoiler: it generally ain't hydration or avoidance of disease.
That's what I was thinking. Why would boiled water kept hermetically sealed in a glass bottle for a year go bad ?
Keeping water fresh is not quite as difficult as you might think. For one thing, wood has naturally antibacterial properties; it can be trivially sealed with pitch and tar (which also has antibacterial properties), and it just takes one quartermaster to babysit it.
If anything, beer is a way of preserving calories and boosting morale. The fact that drinking a gallon of it translates roughly to drinking 97% of a gallon of water and does end up being quite hydrating just doesn't imply that people didn't also drink water sans beer.
Yet people continued wasting resources on time on making beer and similar drinks due to whatever reasons..