The Black Panthers knew this. That's why they went armed to patrol the police. (Then people who were afraid of the Black Panthers passed laws to stop that.)
Protests without armed people "turn violent", by which we really mean, cops go nuts and beat the shit out of people.
Protests with armed people tend to keep the cops restrained, and they have significantly less injury and death.
The weapons serve as a deterrent. Because bullies think they can win in a melee, but they don't want to be killed, and their targets are showing that capacity.