It is calculated from the fund value at the start of the year and a base interest rate set by the government. German banks deduct the tax at the beginning of the following year.
Amounts already taxed are credited when you sell, so you are not taxed twice. With a foreign broker you must calculate and declare it yourself.
Full guideETF taxes in Germany: distributions, gains and VorabpauschaleRelated terms
General information on German tax law, not advice on your individual case.