While the question asks generally about "necessity"-type defenses, there is a need to distinguish between two separate concepts.
Good Samaritan laws
Good samaritan laws "offer legal protection to people who give reasonable assistance to those who are, or whom they believe to be injured, ill, in peril, or otherwise incapacitated".
The typical example would be attempting CPR on an unconscious person and breaking one of their ribs. Breaking someone’s rib would usually be a tort, but as long as the rescue attempt was done in a "reasonable" manner, the rescuer will not be on the hook for medical costs. What is "reasonable" varies across jurisdictions.
Those laws usually imply a subjective element. If a random person at the site of a car crash moves an unconscious body on the curbside to free the road for traffic, that’s probably reasonable. If a first-aid instructor does it, less so (such a person would know that trauma victims should not be moved unless strictly necessary). If the same first-aid instructor moves an unconscious body away from a riverside bed during heavy rain, that might be reasonable; even if it later turns out the rain subsided and no flood occurs, that was a reasonable concern at the time the decision had to be taken.
At common-law, those laws only apply when the rescuer has no duty of care. For instance, suppose a ferris wheel I was riding suddenly catches fire. The ferris wheel operator stops the wheel, sets up mattresses below and asks patrons to jump down onto them to get to safety. By doing so, I break my rib. The ferris wheel operator might not be on the hook for my broken rib, assuming the "jump onto mattresses" rescue plan was the only one available at the time. However, the ferris wheel owner still had a duty of care towards patrons, and should have provided a safe environment that did not require jumping from the height of the wheel. I can therefore still sue for medical expenses. The Good Samaritan law does not "erase" liability caused by creating the dangerous circumstances in the first place.
civil-legal-system would roughly follow the same principles (no tort during a reasonable rescue attempt). The only significant addition is (in most but not all civil law countries) a duty to rescue. The rescue only need be "reasonable" - for instance, if you see a child drowning in the river, you must call the emergency services, but you usually do not have to try to go into the water yourself (because that would put yourself at risk). However, the risk calculation changes depending on whether you are an eighty-year-old teacher or a thirty-year-old Olympic swimmer.
Those laws are about limiting the liability of the rescuer towards the rescued. They do not cover relations with third parties (such as a bad guy on the scene).
Self-defense is the act of defending against a threat via violent (and otherwise illegal) means. The exact scope of self-defense varies across jurisdictions, but to my knowledge it always extends to defending others against a "bad guy", not necessary oneself. (The English "self"-defense is a bit misleading in that respect. The French, Spanish or Italian term translates to "legitimate defense"; the German or Dutch term translates to "necessity/urgency defense".) The scope of what is allowed under which circumstances depends a lot across jurisdictions.
In general, the defense requires a reasonable subjective belief that the threat is imminent (you don’t get to shoot a murderer fleeing the scene), and that the countermeasures taken be proportionate (you don’t get to shoot a brat who is tickling your child).
Some jurisdictions and circumstances require that no otherwise-legal course of action be reasonable (typically, when defending against a threat to yourself, that you cannot flee the scene). Others allow it regardless. Some jurisdictions and circumstances allow lethal action against a threat towards goods; others do not.