Know your rights.
In Canada, under s. 34 and s. 35 of the Criminal Code, you are entitled to defend yourself from attack or imminent threat.
You are permitted to use force that is needed to protect yourself or prevent someone from entering the property, but nothing more.
You can be charged with assault or manslaughter even in cases for defending yourself. This is why it is important to only use physical force as a last resort.
For example, if you were defending yourself against an attacker, did you stop fighting them once they no longer presented a threat? Your actions should be limited to what is necessary to protect yourself or another.