Of course, Madrid knows that he is getting old and will leave the club very soon which made them not interested in keeping him. Maybe, his nature is that he loses this season and wins title the next season, but they are somehow not comfortable with him coaching the club anymore. This was why they brought a younger coach who can spend more time to work and solidify the team so that the trophies will keep on coming in.
Real Madrid does not plan only for 2/1 year, they plan for the long term. Even in the case of buying players, things are the same, they target young players like Dean Huijsen & Trent Alexander, who can support the team for a long time. Also, they do not want to keep very old players, almost every player they buy has to pay high wages. Madrid is very conscious about spending money, and hiring Alonso reflects that vision.
Alonso is only 43 years old, if Madrid is able to perform well next season under Alonso, then Alonso will be the manager of Madrid for the long term, I guess. Alonso does not need to prove his ability once again as he did with Leverkusen last season, a slight improvement, especially in La Liga & the Club World Cup, would be enough for his long-term sustainability with Madrid.