When you reinstalled macOS, did you perform a clean install by first erasing the drive? Did you thoroughly test the clean install before installing any third party apps or restoring from a backup? If not, then you likely brought the problem back.
You can try booting into Safe Mode to see whether you connect to the Internet. If Safe Mode works, then you most likely have some third party software installed which is interfering with the normal operation of macOS. Typical culprits are anti-virus apps, cleaning/optimizer apps, and third party security software. None of these types of apps are needed on a Mac and usually cause more problems than they solve, plus they impact system performance. If you have these types of apps installed, then uninstall them by following the developer's instructions. If you don't have these apps installed or have already uninstalled them, then try running EtreCheck and posting the report here using the "Additional Text" icon which looks like a piece of paper so we can examine the report for clues to assist you.
Are you using WiFi or a wired Ethernet connection?
You do need to distinguish between being able to connect to the WiFi, getting a valid IP address for the home network, and actually accessing network locations outside of your local home network....each of these things are different and we need to determine which one of these items the process fails at. Are you able to successfully connect to the WiFi? The WiFi icon on the menubar should show dark black bars and should show the WiFi information.