I believe the legal stance on this is the lack of control over the dog if it is loosed against an attacker.
A person may draw a gun but then restrain from using it if the attacker backs off.
Once loosed, control of the dog might be difficult and result in injury or death for the attacker even though the attacker backed off.
Even if on the property the attacker should be given a chance (legally) to back off and leave. A dog might not allow this.
If inside the house I believe it becomes an entirely different situation because the dog lives in the house and was not “loosed” upon the attacker.
However, I’m not a lawyer; I don’t even play one on TV.