That doesn't really make sense. First of all, I assume it is an extension AND a salary increase. So unless the guy is playing for free, then the additional cost during the extra years is not 20k, but the full price of 20k plus what they are making now.
Second, it's foolish to assume that player transfer value is only contingent upon their remaining salary years. That's much less of a factor than level of production/wage.
Let's take a simple case. For the sake of argument let's assume that Davis is washed up at the age of 33. Not saying it will happen, but I think we could agree it is certainly within the realm of possibility. His value in the transfer market at that point would be 0. If you are paying him 40k a week that year, then you lost 2m that year.
Another one: What if Jay Rodriguez's knee is crocked and because of that he keeps suffering various injuries, can't stay on the pitch, and is not effective when he plays. So again let's call him close to 0m in the transfer market and 0m worth of production. When we signed him to an extension, it was to fend off supposed interest from Tottenham.
So let's say we could have transferred him for 7m, and obviously we'd have been free of his wages as he was no longer our player. Instead, we signed him for say, 40k a year for 4 years. So receiving 7m, we are paying 8m. That's a -15m swing.
So yes it is easily possible to lose money on an extension. It happens all the time.