I thought that if a coach coaches a national team, it doesn't prevent him from coaching a club... I could be wrong, but I think some coaches have coached national teams and clubs at the same time... Although probably for Real Madrid this option is not suitable... I didn't realise Ancelotti would be leaving the club in a year...
Real Madrid would have honor Anceloti and allow him but this is one of the biggest club we are talking about, they need Anceloti more than any national club need him and that's why he himself will take the job by next year. Brazil isn't even his nationality to begin with, there is no point of doing double work. It will even make him concentrate less in Real Madrid if he should manage to club and there wouldn't be time for rest and vacations because literally he would be active during domestic leagues and Champions league and will take over the national when the domestic leagues resume. There is no way for productivity if national teams clash with domestic leagues, it's better that way to quit the club by 2024 before summer time.
Ancelotti contract with Real Madrid will expire in June 2024, he must leave Madrid if he officially accepts his new job as coach of the Brazilian National Team. I think that the option of coaching Madrid at the same time as coaching the Brazilian National Team is impossible, and that doesn't make sense. Even so, as far as I can remember, Guus Hiddink was once the coach of the Russian National Team and the Chelsea Club simultaneously, but only temporarily (interim).
Guus Hiddink replaced the role of Avram Grant who was fired halfway through and in the remaining matches Hiddink was asked to help the club as much as he could until the end of the season. After the season ended he returned to coach the Russian National Team and Chelsea appointed Carlo Ancelotti as the new coach. There are so many factors why it is impossible to train a club simultaneously with the National Team, even though it has happened like the case above, it is only temporary.