Context tells us. If I say "I need to buy gas before we go on our trip" it is understood I mean gasoline for my car.
We also use "gas" for "natural gas" (methane), piped into our homes for heating and cooking. if I ask someone if their oven is electric or gas, they know I mean natural gas and not gasoline.
They do use natural gas for some motor vehicles now, but this is an exception. If your car ran on natural gas, you would need to specify to people that it ran on "natural gas." If you told people you had a car that ran on gas, they would not find this remarkable.
- For Teachers