Safari and desktop apps have connectivity issues, but chrome and ping work
The proper way on modern macOS to flush the dns cache is:
sudo killall -HUP mDNSResponder

You’ll want ensure your DNS is working well by bypassing your routers provided DNS and manually configuring Google or Cloudflare or other DNS provider on the MBP.
8.8.8.8, 8.8.4.4 is Google
1.1.1.1, 1.0.0.1 is Cloudflare
There are several other DNS providers to choose from. You definitely should use one of these on your router instead of your Internet providers DNS. Not only for privacy but also performance.
Some even setup their own DNS servers and enable DNSSEC, etc. to encrypt the DNS traffic. The Pi-hole DNS filter can block tracking, ads, and known malware sites for your entire network. Although it runs on a Raspberry Pi you can run it on other systems such as Docker, etc
Another possible problem may be a proxy. If this is an employer issued Mac it may be using a corporate network proxy even when you are not VPN connected. Companies are doing more of this due to the pandemic and work from home. If you see a Profiles icon in System Preferences (might have to search for it) then the Mac is managed with Configuration Profiles likely outside your control.
You may need to update the firmware on your router or if the router is older than 5 years consider replacing it.
You should check everything running from /Library/LaunchDaemons /Library/LaunchAgents and ~/Library/LaunchAgents for anything suspicious.