Short answer: Chrome and Firefox both have a built-in setting that makes you hold ⌘Q instead of tapping it. Safari does not have one.
Turn the built-in ones on first. They cost nothing and they are the right fix for those two browsers.
Chrome ships with exactly the guard you want, off by default. In the menu bar open the Chrome menu and click Warn Before Quitting (⌘Q) so it is ticked.
From then on a tap of ⌘Q shows "Hold ⌘Q to Quit" and nothing closes. You have to hold the chord for about a second to actually quit. It is the single best change you can make if Chrome is where you lose work.
Open Firefox › Settings › General and tick Confirm before quitting with ⌘Q. Firefox then shows a confirmation sheet listing how many tabs and windows are about to close.
Safari has no equivalent setting. There is no "warn before quitting" in Safari's settings, and there never has been. Anything that claims otherwise is describing Chrome.
What Safari does have is reopening. Turn off Close windows when quitting an application in System Settings › Desktop & Dock, and Safari brings your windows and tabs back the next time it opens. That does not stop the quit, it just makes it survivable, and you still lose anything typed into a form.
To actually stop the keystroke in Safari you need something outside Safari.
Most applications have nothing. Photoshop, Slack, Mail, Notes, Preview and the rest quit the moment you press ⌘Q, and the reason this happens at all is that ⌘Q sits directly beside ⌘W on the keyboard. Nobody means to press it. They mean to close a tab.
That is why a per-app fix only gets you so far: it works in the two browsers that thought about it, and nowhere else.
You have two options that cover every app.
Remap the shortcut. In System Settings › Keyboard › Keyboard
Shortcuts › App Shortcuts, add a shortcut for a named app with the exact menu title
Quit Safari and assign it something harmless. This works, it is free, and it has two
catches: you have to do it per app with the exact menu wording, and it moves the shortcut rather than
guarding it, so ⌘Q then does nothing at all rather than asking.
Or guard the chord. Still Dock holds ⌘Q and ⌘W for the apps you choose, so the shortcut still works everywhere else. Pick the three apps you keep losing work in and leave the rest alone. There is more in disabling ⌘Q on a Mac and confirming before ⌘W closes.
Yes. It is a Chrome-level guard, not a per-window one.
Only the shortcut you remapped. The Quit menu item still works with the mouse. The risk is forgetting you did it and concluding the app is broken a year later.
There is not one, and there never has been. Close windows when quitting an application is the nearest thing, and it changes what happens after the quit rather than preventing it.
Same neighborhood, different problem, and the browsers do not guard it at all. See confirm before ⌘W closes.