If we play a game of counterfactuals there is a scenario where electric cars could have remained the dominant car type if only some visionary had the insight to figure out how to exploit the existing infrastructure of the early 20th century.
In 1908 there was a better infrastructure for EVs then there was for gas cars. There were no paved roads outside of cities and no gas stations. What did exist were electric trolleys and subways in cities and short line electric railroads that connected cities and towns. All we have left today are the subways and a few trolleys in major cities, the short line railroads were all put out of business by cars in the 1920s. Suppose someone had thought to build an electric car that had the ability to use the power in those systems. An electric car that could run on the short line rail tracks would have been able to go anywhere with no range anxiety. It wouldn't have been ideal, in the same way that dial up modems weren't ideal, but it would have taken advantage of an existing infrastructure just as dial up modems to advantage of the existing voice phone network. When the good roads movement happened in the 1920s and the first paved roads were built they might have had overhead trolley wires or third rails installed. When the Interstates were built in the 1950s they would have been built with power rails embedded in the pavement. If that had happened electric cars would never have needed advanced battery technology to be viable and even with primitive lead acid batteries they wouldn't have needed the huge battery packs that todays EVs require.
One problem was that relatively few homes in the U.S., like less than 10%, were even wired for electricity in 1908. Often those that were couldn't handle a load much more than a few light bulbs.
Out of necessity, WW 1 drove a lot of development in gas engines. Then cheap gas, notably from Texas, Oklahoma, and thereabouts, allowed gas engines to take an insurmountable lead over electric. The technological pieces to make EVs even remotely practical and competitive against gas have only existed in the last 10-20 years - thanks in large part to the computer industry. Li-ion battery technology was the final piece of the puzzle.
The third competing technology back then was steam. Somehow I don't think steam cars will ever return.