Law enforcement doesn’t prevent crime (and there is no legal expectation for them to do so). They disincentives crime by seeking to punish those who previously committed a crimes, and they disincentivize vigilante justice by offering a (ideally) non-emotional legal system alternative to retribution.