I guess what caused Real Madrid losing in the last season is for the fact that they were more focused on winning the championship believing that the local league Spanish La Liga will be a workover for them even though they know the capacity of their closest rival team Barcelona who made a surprising ending to topping the table in the la luga.
There is no luck and they are too focused on chasing the Champions League, so Real Madrid's appearance in La Liga is not fully concentrated. Entering the second half of the season, they also experienced a decline in performance and suffered several defeats which caused their points to be further away from Barcelona. This season they have good strength compared to Barcelona and there are good hopes for next season for Real Madrid.
But then also we can't tell if the coming season will be that lucky for Barcelona because Real Madrid is presently putting in efforts to get the best player onboard the team against the coming.
Both Barcelona and Real Madrid have tried to maximize the team's strengths by trying to sign several players in the transfer market. Real Madrid has clear financial resources compared to Barcelona, so that Real Madrid can maximize the process of recruiting new players.