This situation is true worldwide and across carriers. Ticket prices are based on supply & demand, not distance traveled. Thus, the same physical seat LHR-MAD may cost less than that seat MAD-LHR.
Fare buckets themselves are artificial creations and simply represent a carrier's willingness to sell some number of seats for some given price.
Put simply, there are more people willing to pay a higher price originating at MAD than originating at LHR. Thus, the xMAD price is higher. Currency fluctuations and other issues sometimes play a role, but the bottom line really is demand.