As a general rule, to prevent further attempts. That counts as preventing harm!
(Although note my other post, which expands the definition to include redressal as well.)
There was a story a few years ago of an elderly lady with dementia who strangled another nursing home resident. Despite being an actual murder, it wasn't clear whether or not she'd actually be sentenced to any punishments.