Using Safari's "Manage Website Data..." followed by "Remove All" does not remove databases created by websites. They are SQLite files and are stored in:
~/Library/Safari/Databases
To delete databases created by websites, navigate to that folder and drag its contents to the Trash.
Those databases will return upon loading the websites that create them, for whatever purpose that may entail. It can be assumed they are used to save login credentials and browsing history specific for that website, but other uses are certainly possible and are easily implemented.
macOS draws heavily from its iOS counterpart in that it makes extensive use of sqlite databases. That ability is incorporated in Webkit that Safari uses, and its use is not limited to Safari. SQLite can be used to create very compact and efficient database storage for a variety of purposes. Contacts and Mail also uses them. For more information refer to http://www.sqlite.org/.
Cookies and website data will be populated from sources other than the obvious open pages and tabs. They include Top Sites, Quick Website Searches, Search Engine Suggestions, Top Hits and others.
Also, when you click "Remove All" it will take some time to delete all of them. The window will repopulate before it's finished removing everything, so let it take a moment or two to finish.
Safari for Mac: Search preferences in Safari