If possible, check if your SIM card works fine in another phone.
If you disconnect from Wifi, are you able to use data traffic through 4G/5G? Like browsing the web?
Go to Settings app -> Network and internet -> SIM card -> Your SIM card. Make sure network type is set to 4G (not 4G only) and that 2G is enabled. Try again.
If that does not work. Try also going to Settings app -> System -> Reset and Recovery -> Reset mobile network settings. Try again.