The folks behind restorative and transformative justice have some interesting ideas:
https://en.wikipedia.org/wiki/Restorative_justice https://en.wikipedia.org/wiki/Transformative_justice https://savethekidsgroup.org/defining-transformative-justice...
The cause, frankly, comes from severe psychological trauma that breaks sensible thinking [1]. But, it's no excuse.
The solution? I believe it requires making people more moral, thus making them more just. How to do that is, effectively, something I believe is beyond the scope of my understanding.
[1] http://gainedin.site/ptsd/