It's not the alcohol that's supposed to kill bacteria, it's the long boil.
The boil does kill the bacteria, but it's not preserved after the boil. At best it's as sterile as water; at worse it spoils faster due to the abundance of nutrients.
Yes and ancient Greeks and Romans already knew that boiling water somehow makes it safer to drink.
Yet people continued wasting resources on time on making beer and similar drinks due to whatever reasons..
First of all, many types of beer were historically not boiled. Quite a few still aren't. The mash, however, pasteurizes the beer.
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.