Hi, if you could specify a region/jurisdiction, that could help potential respondents. Meanwhile, you may be interested in a couple of previous answers, both of which refer to the USA:
During the time after cars were invented, but before they became popular, where did people buy gasoline? - featuring /u/mrdowntown
When the first cars began being sold, how was the gasoline distribution? - featuring a now-deleted user account
As has been partly mentioned by others:
pharmacies (during the first roadtrip with a car, the driver, Bertha Benz (wife of Carl Benz, the inventor), "refueled" at a pharmacy)
drug stores (they focused on special chemical substances)
inns (later, once cars became a little more common).
retail stores
But I would also like to address a few points:
where and how did everyone buy their gasoline?
Hardly anyone had a car until Ford came along. Only millionaires could afford cars. By the time cars became common, rich car enthusiasts had already built-up a certain infrastructure that was then expanded. This, of course, had happened gradually. There was no sudden switch to cars and hardly anyone of the early adopters needed a car. Even if they had run out of gasoline the worst consequence would have been a spoiled Sunday road trip.
where and how did everyone buy their gasoline?
Early on it was not clear-cut that gasoline would become the standard fuel. It competed with electric cars, steam cars, … Especially electric cars had a number of advantages over early gasoline cars (no stench, no loud noises, no need for a transmission, …). However, the fatal disadvantage of short range and a few other factors made it less competitive than the gasoline car (“Gasoline became suitable for the city. Electricity did not become suitable for the road.”)
It should also be noted that gasoline was only one out of many bottlenecks. Early cars were sensitive to break-downs in a way modern drivers cannot imagine. Early tires were very weak and needed lots of replacements. And a lot of other elements needed spare parts. However, as only rich people could afford cars anyway, they had no problems in organizing the support environment their cars needed. E.g. spare parts and gasoline could be transported by train to where you needed them.