I imagine most mobile apps have access to the basic dialer info of the phone they're running on.
Apple actually doesn’t expose this via any iOS APIs. Not 100% sure about Android.
Does it expose any sort of "device id"? Such ids are usually asked for by advertisers and iOS and Android gladly give it to them. I'm sure there are device-id to phone-number maps out there, and anyone with money can get access to them.
Unique device IDs are app-specific.
The device id that you can get via any SDK on ios is not real. And, even if you can get by any other means then Apple would not approve your app.
Consider _any_ app you've linked your email and phone number to, could (in theory) sell access to your data to any other company that only has your email, and they have both. Or (as another commentor noted) the great many apps that upload your (friends) entire contact list. Consider all the id's, fingerprinting techniques (etc) out there, juxtaposed against the high value that information has (in marketing / ad space) and it seems likely there are many ways to get this information, whether or not you provided it.
Pretty sure Android does. TikTok knew my phone number before I gave it to them.
On Android you need to give it the READ_PHONE_STATE permission.
Could be as easy as a friend of yours uploading their whole address book (ostensibly “to find friends”)