Go step by step and test.
1. Restart the router.
2. Deselect Proxies, if selected.
System Preference > Network > Advanced > Proxies Tab
Unlock the lock if you have to.
Under "Select a protocol…”, uncheck any box if check-marked.
Click "OK” then "Apply”.
https://support.apple.com/guide/safari/if-you-cant-open-a-website-ibrw1071/mac
3. Uninstall any Profile you have not installed knowingly.
Section: Remove a configuration profile from your Mac
Profiles: https://support.apple.com/guide/mac-help/configuration-profiles-standardize-settings-mh35561/mac
3. Disable/uninstall any anti-virus software or web monitoring software if installed.
4. If you cannot still connect to internet:
Startup in Safe Mode. https://support.apple.com/lv-lv/HT201262
Login to your account. Launch Safari and test.
Logout and restart .
5. Contact t-mobile