The Roman title of Dictator is different from a modern day dictator, agreed — but if you read carefully no-one argued otherwise. The Roman title of Dictator more aligns with the modern concept of "emergency powers."
If you have bigoted populace, it's dead easy to bait them into voting for some immediate emotional relief. Sri Lankan's wanted to have fun watching Tamils and Muslims get hurt, so it wasn't all that hard for some politician to get the people vote for him. The worse thing is they even put up with his bad decisions for the same reasons. And they did this for years.
The population is entirely responsible for this.
As it turns out they ran out of time, there's always that one point after which everything comes melting down.
As soon as you have a government run for the benefit of a small group, you no longer have a democracy.
Elections don't change this. Not even nominally free and fair ones.
The problem - as always - is that any system of government trends towards capture by Dark Tetrad types. No matter what decisions they appear to make, and no matter whether they're left/right populist/monarchist democratic/authoritarian, the consequences are always disastrous.