Vigilantism is no better than a criminal justice system. You still have rules that you must follow, and punishment for those who break the rules. Vigilantes could even lock someone in a cage if they felt like it.
So I don’t see why you prefer subjecting someone to the whims of vigilante mob than to much more predictable criminal processing. If anything, vigilantes have embraced racism and class preferences far more openly than our legal system.
And laws do stop people from doing bad things. That’s why lynching suddenly became less common after it was outlawed.