A post on Stack Exchange can contain a link to any website. This is no different from any other website. Like pretty much any website with externally contributed content, even if you trust the site owners, you can't trust all the contributors.
Do note that Stack Exchange posts can embed images that are hosted on external servers. This doesn't make them potentially malicious, but it can be a breach of privacy. If you view a post that embeds an image that is hosted on a third-party server, then the administrator of that server will know that your IP address viewed that image on that date.