Your MacBook Air’s hardware specifications do not , by themselves, suggest that storage or RAM is the problem.
Since Chrome is working normally on the same Mac, I would focus first on Safari and anything that can affect its operation.
Start by going to System Settings >> General >> Software Update, install any available update, and restart your Mac. Safari is updated through macOS. Apple: If Safari doesn't work as expected on Mac
Next, turn off all Safari extensions under Safari >> Settings >> Extensions, quit Safari, reopen it, and try YouTube and a few other sites.
If you use a commercial VPN, antivirus, firewall, web filter, DNS filter, or other third-party security/network software, temporarily disable it and test Safari again.
If you use iCloud+, try bypassing Private Relay for an affected website by choosing View >> Reload and Show IP Address in Safari.
Then open File >> New Private Window and test the same sites.
If they work normally there, go to Safari >> Settings >> Privacy >> Manage Website Data and remove the affected website's data.
Since you have already found that clearing Safari's history and cookies only fixes the problem temporarily, I would not keep repeating that as the main solution.
If the problem continues, take a look at Safari's Privacy, Security, Websites, and Advanced settings, particularly anything affecting JavaScript, cookies, content blockers, or website access.
It is also worth checking System Settings >> Network >> Wi-Fi >> Details for any custom DNS or proxy settings.
If possible, try Safari on a different Wi-Fi network as well. That can help determine whether your current network is involved.
Because Safari is also crashing, if it becomes completely unresponsive you can use Option–Command–Esc to force it to quit.
If the crashes continue, try starting your M4 Mac in Safe Mode and test Safari there.
Apple notes that Safe Mode can help determine whether software that loads during startup is contributing to a problem.
You can also test Safari from a temporary macOS user account.
If Safari works normally there or in Safe Mode, that would provide useful evidence that something associated with your normal user account or startup environment may be involved.
o avoid a game of 20 questions
Download the Application Etrecheck ( External Link ) directly from the Developer.
This is a Diagnostic Tool that makes no changes to the computer.
It makes a coherent and readable inventory of both the Hardware and Software used on the computer
The application is free or paid for added features.
The Report will Not Reveal Any Personal Information.
Post back the Full Report - Share Report >> Copy , then paste >>>> using the Additional Text Icon <<<<
