You can’t make an unbreakable system, or, at least, it’s very difficult.
The problem is that a big percentage of the population is ok with this, and in that case it doesn’t matter if it’s illegal or not. There is a reason why, even if allowed, governments didn’t do these kind of things: population didn’t want it.
Unless that "big" percentage is an outright majority of the citizenry --- not a majority of congressional districts, not a majority of electoral college votes, not a majority of the votes in the last election, but an outright majority of the actual desires of all citizens --- then the system is broken. I'm pretty sure that is not the case; it's at least debatable. But the problem is that we've bought into a system that says that doesn't matter.
The problem is that a big percentage of the population is ok with this, and in that case it doesn’t matter if it’s illegal or not. There is a reason why, even if allowed, governments didn’t do these kind of things: population didn’t want it.