It's even worse if you use iMessage. If you take out your usual SIM card to replace it with a foreign one, people can't iMessage you anymore, unless they use your Apple ID (email address) for it. Other apps like WhatsApp have an option to keep using the previous number even in the absence of the SIM card.
This shouldn't happen unless you intentionally switch your account over, which might happen due to Apple's persistent nagging with the red bubbles on iCloud and iMessage settings suggesting you to.
It seems to be new behavior introduced in iOS 12. I’ve observed this too, when doing a brief SIM swap. All it took was removing the SIM, and the phone automatically de-registered that number from iMessage.