If you are seeing scam notifications pop up briefly in the upper right hand corner of your Mac's screen, these are Web notifications. Block them in Safari as shown here: Stop unwanted Notifications - Apple Community . If you use any other Web browsers, block Web notifications there, too.
If you go to a Web site and a scam message hijacks the screen, you may need to Quit or Force-Quit the browser. One way to do this is to right-click on the browser's icon in the Dock and select Quit or Force Quit (as applicable) from the menu.
Then hold down the SHIFT key and re-launch the browser. Clear your browser history (so you don't accidentally select the site that abused you in this fashion by mistake), and avoid going back to the abusive Web site.
Prevent apps and windows from reopening on Mac - Apple Support