Try booting into Safe Mode to see if that allows you to access the Internet since Safe Mode will prevent third party software from launching automatically during boot & login.
If you have any anti-virus apps, cleaning/optimizer apps, third party security software, or VPN software installed, then uninstall them by following the developer's instructions. These types of apps are the ones most likely to affect your ability to access the Internet. None of these types of apps are needed on a Mac, plus they usually cause more problems than they solve.
Also, disable or uninstall any browser extensions & plugins that you may be using. Many of them can cause issues as well.
You can also try creating a new macOS user account. Log out of your main user account, then log into the new user account. See if you can access the Internet now.
Did you (or someone else) possibly enable any macOS security features to limit the functionality of your macOS user account? Or maybe you have some customized network "locations" which may not work at your current location....the other macOS user account should get around that possibility since it should only have the default macOS network options.
You can also try running the Apple Diagnostics to see if any hardware issues are detected. Since the Apple Diagnostics are online, this is another way of finding out whether the issue is with the hardware or macOS. You may want to perform a PRAM Reset (hold the PRAM Reset for two chimes if possible...not always possible with the 2019 model).
Here is an Apple article with instructions for reinstalling macOS:
How to reinstall macOS - Apple Support
Before reinstalling macOS, make sure you have a good backup before you do anything else. There are so many new ways of permanently losing access to your data with the 2018+ Macs.