For example, in the US, the Supreme Court is able to expand its powers, but it can always be overridden by the legislative branch by design. The executive branch doesn’t even have to follow the Supreme Court’s rulings. And the legislative and executive can be replaced by citizens.
By design, the US Constitution basically has an infinite loop of checks and balances - there is always another institution that can override one institution without breaking any rules.
That said, the buck does stop, but it stops at the people. The problem is that people do need to be well-informed and vigilant to for the this scheme to work out, but to be honest, that is not a problem specifically with democracy — it’s just a general societal problem.
There have been recent Supreme Court rulings that many would say are disagreeable, but we’re not doing anything about it because a lot of citizens either support it or just don’t care. But if citizens did, we could easily undo those decisions using the rules set out by the Constitution. So the problem really lies more with the people than the system.
Now I’m not familiar with the Brazilian political system — who checks the Supreme Court there? I just know the US Constitution had a LOT of people working on it and they covered a lot of bases.