Infrastructure requires demand, and energy density and convenience of a contemporary battery versus gas engine means that no one was going to demand batteries when ICE was an option. We only figured the downside much later.

We figured out the effects of carbon dioxide on the atmosphere not a decade after the first working car prototype was build: https://www.rsc.org/images/arrhenius1896_tcm18-173546.pdf