A woman gets raped so she buys a gun for self protection due to learning from that experience in terms of what happens when unprotected in some way.
No different than wearing condoms during sex.
Those who end up with aids or pregnant learn ways to make sure things like that never happen again due to the fear of it from happening again.
Same with genocides, wars, bad policies, greed etc…
Without all the bad we could never reach for the good. ⁂