There is actually a paper on this topic by Beyer et al (2009) titled ‘Opting out of the great inflation: German monetary policy after the breakdown of Bretton Woods’ that exactly addresses your question.
As the authors explain:
During the turbulent 1970s and 1980s the Bundesbank established an outstanding reputation in the world of central banking. Germany achieved a high degree of domestic stability and provided safe haven for investors in times of turmoil in the international financial system… We derive an interest rate rule and show empirically that it approximates the way the Bundesbank conducted monetary policy over the period 1975-1998. We compare the Bundesbank's monetary policy rule with those of the FED and of the Bank of England. We find that the Bundesbank's policy reaction function was characterized by strong persistence of policy rates as well as a strong response to deviations of inflation from target and to the activity growth gap. In contrast, the response to the level of the output gap was not significant.
Basically, to sum up and bit oversimplify the paper, it was thanks to Bundesbank’s masterful use of inflation expectation anchoring as well as pursuing relativity tight monetary policy.
Moreover, Germany was viewed as a safe country for investors so it had capital inflows that also helped.