Ancelotti was sacked for playing shit in the CL and for getting on the wrong side of our best players while being just 3 points from the top of the league. Also Kovac was under fire early on and would probably have been sacked earlier if Uli hadn't been stubbornly defending his mistake of appointing him.
If Bayern were as ruthless as they supposedly will be with Flick neither Kovac nor Ancelotti would have survived (after) their first season. Especially with Kovac everyone knew that disaster was merely postponed. And I don't even mean that as criticism, in the end even the most principled management has to abide by the results to some degree.