Is this self defence?
German self-defence laws may be found in within Chapter 2, Title 4 of the German Criminal Code at sections 32 to 35:
Section 32 Self-defence
(1) Whoever commits an act in self-defence does not act unlawfully.
(2) ‘Self-defence’ means any defensive action which is necessary to avert a present unlawful attack on oneself or another.
Section 33 Excessive self-defence
Whoever exceeds the limits of self-defence due to confusion, fear or fright incurs no penalty.
Section 34 Necessity as justification
Whoever, when faced with a present danger to life, limb, liberty, honour, property or another legal interest which cannot otherwise be averted, commits an act to avert the danger from themselves or another is not deemed to act unlawfully if, upon weighing the conflicting interests, in particular the affected legal interests and the degree of the danger facing them, the protected interest substantially outweighs the one interfered with. However, this only applies to the extent that the act committed is an adequate means to avert the danger.
Section 35 Necessity as defence
(1) Whoever, when faced with a present danger to life, limb or liberty which cannot otherwise be averted, commits an unlawful act to avert the danger from themselves, a relative or close person acts without guilt. This does not apply to the extent that the offender could be expected, under the circumstances, to accept the danger, in particular because said offender caused the danger or because of the existence of a special legal relationship; the penalty may, however, be mitigated pursuant to section 49(1), unless the offender was required to accept the danger on account of the existence of a special legal relationship.
(2) If, at the time of the commission of the act, a person mistakenly assumes that circumstances exist which would provide an excuse under the terms of subsection (1), that person incurs a penalty only if the mistake was avoidable. The penalty must be mitigated pursuant to section 49(1).
Section 49(1) provides for a reduction in sentence if offender is found culpable by the court
Ultimately it would be a matter for the judge(s) to decide, but given the circumstances in the OP I suggest that being kidnapped and then "confronted by the kidnapper" who has a firearm equates to a s.32(2) "unlawful attack".
s.33 appears to adequately cover Hostage A's use of Hostage B as a human shield in the given circumstances, as do the first sentences of s.34 and s.35 for Hostage A's justification and necessity for doing so.