My Mac is opening new tabs with different ad sites
How to install adware So you ignored all the red flags given in this apple support post. 


  installation of software from mac-torrent probably


If you're using torrents, use some reputable sources to get them.


  probably it was adobe flash player. 


So if it is not your intended app, why go ahead and install what is dumped on your device?


  said that I had an old one and the system needs to update,


Did you really have an Adobe Flash player version installed? It is not installed in an out of the box setup. And if you installed it from Adobe's site, you'd know what a genuine package look like and you'd be able to update it using the app itself.

In case you don't know where Adobe Flash player can be seen, Safari Preferences → Extensions, and System Preferences → Adobe flash Player. 


  so I gave the right to install it,


Boom.


  the only way to stop this irritating behavior was to install Adblock, however, I don't want my mac to have that malware,


Ad blocker apps certainly won't solve the underlying problem. They don't even operate outside the browser.


  and has anyone experienced it?


Apple Discussion forums are full of it.


  is there any way to get rid of it?


Restore from backup is the best way.

OR

Quit or Force quit(cmd shift escape/ Apple menu → Force Quit... ) Safari. Hold shift and click on it from the Dock. Go to its preferences → Extensions and remove any unknown extension there. Go to Websites tab and remove extraneous items like Flash Player from the lower left corner.


https://www.thesafemac.com/arg/
https://www.malwarebytes.com


Get MalwareBytes app and/or BitDefender, from the genuine source and run a scan. 


Can .mp4 files infect my Mac with malware/adware/spyware? 
How to remove Trovi malware from Safari?