I have been trying to narrow it down in a copy of the production database, so it's being worked on. It's my youngest sons birthday today, so I'll have more time to fiddle with it tomorrow.
But yeah, there's a function in simplemachines that "rewrites" the URL to something that was deemed more search engine friendly back in the early 2010's. Time has moved on and such rewrites are not compatible with newer web servers. Looking back at older posts, it was turned off in the very beginning and turned on some time around 2018 or so.
So it's either that we poke at the database, or edit every link in every post as we stumble upon them. Hacking up the web server to support this rewrite rule probably breaks something and running an old version of the web server just for the links is not really on the table.
We're using the "real" and "unmodified" URL's now, so the best solution and future safe solution is to use what we have now and edit the older posts manually or scripted to change them to the correct URL.