If you can't prove that you need to cut the person for "operational" reasons (e.g. because you're not really getting rid of python tooling engineers), then your best bet is to dangle large cash offers to people in order to entice them to quit.
If they do manage to prove they need to do layoffs, for example when the company is literally running out of money, then they're not allowed to just lay off employees as they like (and definitely not in relation to performance). Instead they have to follow the "Sozialauswahl" which means that factors like whether the employee is supporting a family, is older, etc need to be taken into account.
Then on top of all that, they won't be able to hire people even for completely unrelated roles, for some amount of time afterwards.
So all in all there's a few disincentives for layoffs to be considered as a first action (it's not stopped it from happening at a bunch of companies lately though, Bosch, SoundCloud, Ableton, Native Instruments, Personio, Pitch etc).
[Source] Random link from the Internet so that I don't need to translate: https://www.emplawyers-muenchen.de/wp-content/uploads/files/...
Generally, workers rights here in Germany are quite good so as an employee life tends to be quite comfortable since you don't have to fear termination the moment the company isn't doing exceptionally well.