It does't need a phone number at all, unless you lose access to all your trusted devices and cannot get the code any other way, there should be no real need for a code to be sent to a trusted number.
Also as mentioned unless you are constantly logging in to Apple services from untrusted browsers or devices or are adding new devices to your Apple ID you should not be seeing or need 2 Factor authentication at all.
The need for an actual phone number to call or message is an extreme case when no other method of getting the code is available and again only if you are signing in to Apple services from untrusted devices or browsers or are adding new devices to your Apple ID.
If it is required, the code, as mentioned, can be sent via voice call to any phone number than can be called. It does not need to be through SMS.