So in Germany, you need to prove your identity to buy a SIM card. You can't really buy an anonymous phone, because every SIM card is tied to someone's identity.
This probably doesn't prevent SIM swapping entirely, but you will need to also steal the other SIM card you're swapping the number to.