Internet issues can be very difficult to troubleshoot without seeing what is happening first hand.
First steps would be to connect the computer directly to the router with an Ethernet cable so you can eliminate WiFi issues contributing to the problem. Also rebooting the modem, router, and computer are easy steps to take. Let the modem & router five minutes to finish rebooting before booting your laptop.
Try booting into Safe Mode which disables any unnecessary drivers as well as Startup & Login items.
Create a new user account and test the internet connection.
Does the issue happen to every website that is visited or just certain ones?
When the issue occurs verify the computer can access & communicate with the router. Don't just rely on the WiFi icon. A browser should be able to display the router's administrative login page.
There could be a DNS issue so try using other DNS servers. Try connecting to "google.com" using an IP address (172.217.12.142) instead to help eliminate a DNS server issue.
Check for anti-virus and other third party security apps which may be interfering or "protecting" the user. You can run EtreCheck which will list all the third party items running on the system. Post the report here using the "Additional Text" icon which looks like a piece of paper. Contributors here can point out any items which are known to cause problems.
Here are are some Apple articles:
https://support.apple.com/en-us/HT202663
https://support.apple.com/en-us/HT202480