Have you tried unplugging your modem and/or router for a minute and reconnecting power to them? Give them at least five minutes to finish booting before you reboot your Mac to test the connection.
You need to figure out whether the issue is with connecting to your home network, or whether the issue is with your ISP or your local Internet. You can use the Apple WiFi troubleshooting tool found on the context menu when you Option-click on the WiFi icon. Here is an Apple article for troubleshooting WiFi issues:
If your Mac doesn't connect to the Internet over Wi-Fi - Apple Support
Try creating a new user account and testing the connection while logged in with the new user account. It is possible you have a configuration setting issue, browser extension issue, or a macOS network configuration issue.
Also try booting into Safe Mode which will disable third party items and even login items which will eliminate many potential software issues.
If you are using any anti-virus apps, cleaning apps, or third party security software, then uninstall them by following the developer's instructions. These types of apps are not needed on a Mac and usually cause more problems than they solve plus they impact system performance. You may also want to remove any browser extensions.
Do you have the same issue when using a different browser?
Do you have any other devices connected to your home network? Do they experience the same issue? Perhaps one of those other devices is causing the problem. Try disconnecting each other device from your home network in case one of those devices is causing the problem. You may also have a faulty router or modem. Make sure the firmware of the router is up to date. The router should have an option to reset the router to factory defaults (make sure to at least reconfigure the router by disabling external administrative access and to change the administrative password of the router).