It is illegal but very common. Many of those emails with unsubscribe links are unsolicited. They either spam all their former customers no matter if they have opted in or not or they just buy links. Yes, the unsubscribe links work but what they do is in obvious violation if the gdpr and other laws.
Very few companies would risk those lawsuits, especially in Europe the fines can get rather exponential for repeat violators and I don't think it's much different in the US either. If the unsubscribe works, that is the end of the story for me, and a reminder to check for small newsletter checkboxes when signing up to things.
I very rarely get marketing mails from any reputable company that are completely unsolicited. In most cases it's a followup from trying out an offering or updates to products I'm using or are adjacent to those. If I'm not interested, I either ignore them or unsubscribe if it's repeatedly not interesting.
This is a much more effective "spam" strategy compared to "all HTML is spam".