The sentence "Compro la gasolina en la estación de servicio" means "I buy the gasoline at the gas station."
If we substitute "la gasolina" with a direct object pronoun, we use "la," because "la gasolina" is feminine and singular.
So, the modified sentence would be:
"La compro en la estación de servicio."
In this case, "la" serves as the direct object pronoun that replaces "la gasolina." We use "la" because it corresponds to the feminine noun "gasolina," and it indicates that we are still referring to gasoline but now in a more concise way.