I wouldn't put the blame on Ancelotti or the players, because the team lacked the quality of a good defense and midfield due to injury on their players which started in the beginning of the season. Ancelotti has done his best for the club and he has to leave, let someone else take over. If a coach continues winning trophies, no club would replace him.
Nobody expected so many defenders to be injured, and Ancelotti certainly doesn't want to be in that situation. But strangely, when it happened, and he had the chance to fix things (when the January transfer window opens), he did not take advantage of the opportunity, and it was as if he underestimated the problems they were facing. So for that reason, Ancelotti is indeed to blame for their failure.
I think that's the reason why he stepped down, because he felt he had made a mistake that made Madrid fail to win a trophy.
There is no doubt Carlos Ancelotti underestimate things and get poor result but here need to understand few other things as well which are also important like budget and availability of required players because without having back of management coach alone not able to bring new signings.
While Injuries are always biggest headache for clubs because many clubs faced things like these and have worst end of their season because they were never been well-prepared for this even two windows are working and giving them chance for having suitable replacement but still budget is also important. After winning double they were doing good job, but sadly injuries hits them hard, and they were not able to have things well under control so they face consequences and Carlos also lost his job but still all is well.