While certainly we should do more to prevent the circumstances that cause people to commit crimes, ultimately they don’t eliminate crime and so you still need those deterrents.
In the US we specifically prosecute people for things like buying stolen goods or being an accomplice in crime because otherwise you have people who are actually intending to and do commit crime pretending like they weren’t.