All domestic businesses (B2B) and consumers (B2C) in Germany must pay VAT (Mehrwertsteuer).
A company in the EU (but not in Germany) with a valid EU Vat identification number may be invoiced with Zero VAT according to Intra-EU VAT rules. Similarly, companies outside the EU may also be Zero VAT invoiced.
Consumers and businesses in Germany must be invoiced with the correct VAT rate for the products or services offered.
Magento 2 has built in VAT Id validation see the official documentation for more information : https://docs.magento.com/user-guide/tax/vat-validation.html
I can also recommend the following commercial module that extends the built in functionality and allows you to create customer groups and VAT rules for Domestic, Intra-EU and Worldwide trading : https://technology.pillwax.com/software/euvat-for-magento.html
Further information on how VAT Invoicing works in the EU can be found here : https://www.hellotax.com/blog/taxation/invoice-without-vat/eu-countries/