Good question. Firstly, since the alternative was the horse, there really wasn't the expectation or need to travel long distances. What was deemed to be the first cross-country automobile journey in Germany 1888 was only 66 miles. Hardly astonishing by today's standard and much less than how far you can travel between charging in an EV. But back then it was monumental! As for fuel:
With no fuel tank and only a 4.5-litre supply of petrol in the carburetor, she had to find ligroin, the petroleum solvent needed for the car to run. The solvent was only available at apothecary shops, so she stopped in Wiesloch at the city pharmacy to purchase the fuel. At the time, petrol and other fuels could only be bought from chemists [pharmacists in US English], and so this is how the chemist in Wiesloch became the first fuel station in the world.
In the early days, drivers could buy fuel in cans at any general store, hardware store, some blacksmith shops, and even mail order! They didn't need a massive infrastructure, just a tank to store the gas. They didn't need to worry about compatible sockets, or adding an power infrastructure that would not cause issues for other power users. But more importantly, there wasn't an impending climate crisis giving the government an urgent incentive to roll out charging stations at an accelerated rate.
There also wasn't any real competition for the car, as most people relied on walking, horses, trains, and trams. Today, electric vehicles have to compete against a VERY prevalent existing mode of transport. You simply cannot compare the need for charging stations now verses in early days of the automobile.