Apple will never pop up dialogs in Safari, or any other browser, which isolates what you are experiencing to very real looking SCAMS. Click no buttons on these dialogs, not even a cancel button. As there are no viruses on the Mac, and no one can sweep your Mac remotely anyway, this is just another SCAM along with the bogus Flash Player nonsense.
Force quit Safari (option+command+esc keys) or option-right-click on the Safari Dock icon and select Force Quit. Now, do the following:
- Hold the shift key when launching Safari. This will prevent bad stuff from loading.
- In Safari Preferences
- Advanced panel, [√] Show Develop menu in menu bar
- Press the option+command+e keys to clear your browser cache. The Develop menu bar item will flash to confirm.
- Extensions panel
- Disable, or remove all extensions
- Safari menu : Clear History… all history : Clear History
- Also clears all cookies
- Quit Safari
As you can have a adware/malware infection, download and install the free Malwarebytes for Mac to scan and offer to remove anything that it finds. This is a 14-day "realtime" trial, and afterward it disables the realtime features but allows you to continue using it interactively. Once you have performed the Malwarebytes sweep, you can start Safari again normally, and see if your intrusion pop-ups have gone. Many of us recommend and use Malwarebytes, but frankly, if one watches which sites they visit, and only download software from the original vendor, the adware/malware issue is almost eliminated. On websites that are just a quagmire of download buttons and rollover links, just avoid the site as nothing good can come from anything there.
I have removed all traces of the legitimate Adobe Flash player from my Mac.
Effective defenses against malware and other threats
Protect your Mac from malware
Virus, Trojans, Malware - and other aspects of Internet security
macOS - Security built-in
Virus or Malware?