Let x be the number of gallons of gas used by the first car and y be the number of gallons of gas used by the second car.
x + y = 55 gallons
Since the first car drove 25x miles and the second car drove 15y miles,
25x + 15y = 1125 miles
Solving the first equation for x
x = 55 - y
and substituting into the second equation
25(55 - y) + 15y = 1125
we find that
-10y = -250
y = 25
so the second car consumed 25 gallons
55 - y = x
and the first car consumed 30 gallons.
Whenever you have two variables, set up two equations, isolate one of the variables in one equation, and insert it into the other equation. This gives you the value of one of the variables, which you can then use to find the other variable using either equation.