I don't know Germany, but I'd start with question-based decision making.
- What can I legally own and is it what I would consider acceptable and adequate?
- What guns can I easily/conveniently acquire and feed?
- What kinds of ammunition can I conveniently an legally own? (JHP, JSP, FMJ only, etc)
- What are my particular situational requirements/limitations? (IE, what might work very well for an apartment dweller may be a horrible choice for a farmer and vice-versa.)
On the specific question of 9mm vs 223 in a carbine, my primary personal defensive carbine is a 223 AR, set up pretty typically. But I also have 9mm carbines and I'd have absolutely no problem trusting one of them for close-range defensive use - if loaded thoughtfully. If all you can get is fmj ammo, I'd HUGELY recommend the 223 over the 9mm.
But if you can get better ammo, the 9mm carbine can do surprisingly well, as long as you realize it will never truly equal the 223 carbine. Some numbers I've clocked from one of my 9mm carbines; showing load, bullet weight, velocity in fps, and ft/lbs of energy, in descending order of muzzle energy. These are five-shot string averages. The corbon pow'rball stuff is listed twice simply because I initially didn't believe the results and so ran a second five-shot string to confirm.
CorBon Pow'rBall +P 100 1839.4 751.1
CorBon Pow'rBall +P 100 1812.8 729.5
Fed 115 +P+ 9BPLE 115 1615.8 666.5
Corbon 115 JHP 115 1609.2 661.1
WWB 115 JHP 115 1505.4 578.6
Blazer Brass 115 FMJ 115 1448.0 535.3
Corbon 125 JHP 125 1367.0 518.6
WWB 115 BEB 115 1341.3 459.3
WWB 115 FMJ 115 1323.8 447.4
UMC 115 FMJ 115 1311.0 438.8
Fed Hi-Shok 147 JHP 147 1147.8 429.9
Corbon 115 DPX 115 1249.6 398.6
WWB 147 JHP 147 1053.4 362.1
Fiocchi 158 FMJ-RN 158 907.6 288.9
Loaded with the Fiocchi 158-grain fmj, imo it'd be a very poor choice. But loaded with something better, it could do quite well. Many of them exceed 10mm handgun performance and several of them exceed .357 magnum power levels. Most people don't realize (and some simply refuse to believe) that a 'puny' 9mm carbine can approach the muzzle-energy levels of a .41 magnum revolver; yet two of the corbon loads and the 9BPLE are all solidly in that neighborhood. Will it ever equal a 223? No. But it's certainly nothing to scoff at.
Of the two, I'd recommend the 223. But if for some reason a 9mm carbine ends up in your hands, I wouldn't sweat it that much. Load it smart, put a good red dot on it, and then train and practice with it. And then train and practice with it some more. A hail of ~700 ft/lb bullets launched into your attacker's rib cage should really put a damper on their day. I know it would on mine.