Hi there anacostapinto,
We'd suggest starting by properly blocking pop-ups in Safari with the guidance here: Allow or block pop-ups in Safari on Mac - Apple Support
You'll also want to delete any third-party security software that you may have installed on your Mac, as it isn't necessary and could be contributing to the issue.
Next, start your Mac up in safe mode and attempt to remove any unrecognized files or applications in Finder while in safe mode. Learn how here: Use safe mode on your Mac - Apple Support
If this behavior persists, you'll want to reach out to Apple Support directly for further assistance. They're best-equipped to take a closer look at the issue and provide some additional guidance. This link will help you get started: Apple Support
Take care.