I'm planning on visiting Germany/other countries like 40 up to 60 days a year and might buy myself a new flat/house in Germany/other countries from time to time. My country of residence would stay Malta for a couple years at least, so I don't want to lose my tax advantages just because I'm investing in real estate which will be used as holiday homes or rented to family members.
That sounds like a high risk idea. You’ll really want to talk this through with a German tax lawyer. Lots and lots of things can go wrong there.