Years ago it would be possible to be exposed to malware by simply visiting a website; this is called a "drive-by download." Most modern web browsers block these by default, and most modern operating systems don't allow the malware to be installed.
So assuming you haven't disabled all of the security protections on your Mac or whatever browser you used (and said browser isn't ancient), and assuming you didn't click OK on any prompts or enter your system password to allow an install you should be fine.
You could, however, have been exposed to various tracking cookies, again depending on the browser you used. Firefox and Safari are better at blocking these than Chrome (Edge is somewhere in the middle). If you'd like to be certain that there aren't any tracking cookies from those websites I would recommend clearing your browser's cookies and browsing history.
Even if the website you were directed to featured drive-by download malware it's unlikely it would be targeting macOS, it would likely be a Windows-targeting threat.
There are free antivirus solutions from reputable companies you can install if you want to scan your system just to be safe (Avira is a free one I've used in the past when my corporate VPN required an antivirus solution be installed).