Recall your d = rt, distance = rate * time
so, notice, it went 504 against the wind, and the return trip, well, unless the road elongated or shrunk somewheres, the return trip is also 504 miles.
now, if say the plane has a still air speed of "p", and the wind has a speed of "w", when it was going against the wind, it wasn't really going "p" fast, it was going "p - w" fast, because the wind was subtracting speed from it.
now, when it was going with the wind, it wasn't going "p" fast either, it was going faster, at "p + w" fast, because the wind was adding to it. thus