I have checked for extensions but there are none installed on the laptop, and I have checked everywhere in Finder to no avail. This is also happening on Chrome and would probably happen on Firefox and other browsers. The tabs that pull up seem to be from the search history because the tabs are usually sites such as Amazon. I have only had one or two encounters with actual scam sites. It also usually happens when a website is loading. The laptop used to have another virus where the search engine was replaced and notification windows popped up in the corner of the screen to make money (The current symptoms that I am experiencing happened with this virus as well). I can't remember what the virus was called.
A new Update for Safari was released on September 22nd 2019. As that introduced a totally new safari version. This problem should no longer occur. Make sure the Mac is updated.
Also if it still continues make sure the keys
N are functioning properly. As due to faulty butterfly keys if these two are simultaneously pressed it should result in tabs being opened.