You can completely opt out of the credit card spam ones with a simple sign up on a federal website, but I forget the exact one and am too lazy to hunt it down. Only lasts 5 years though
Or you can do a full mail in thing for the lifetime one, might do that since I just hit my 5 year and started getting spam again
It's not a federal website, it's a "joint venture among Equifax Information Services, LLC, Experian Information Solutions, Inc., Innovis Data Solutions, Inc., and TransUnion, LLC (collectively the "Consumer Credit Reporting Companies")."
So it's not technically government-enforced in any way, but the credit bureaus just kind of decide to honor it to be... nice?
I know nothing about this but top of my head it sounds like one of those self-policing things companies do to keep from being regulated. So they'll honor it if you jump their hoops, but so few people even know the hoops are there it works out for said company to honor the few that do, and they will, to keep that regulation from ever appearing.
Only works on first and second class mail, and just be unopened. I've been doing this for years and I get maybe 1 credit card offer a month. It's now at the point where most of my mail is actually stuff I want/need and only get mail like twice a week.