I'm not super familiar with it myself (obviously, everything's super-illegal / open to being sued, which makes open discussion non-existent), but in some cases they use AI to decompile the original game and recompile it with additions to the code, in some cases they decompile both games and create a pseudo-hybrid where chunks of both game are running simultaneously - I believe for things like this:
Batman is the primary game running but passes the world geometry to a chunk of the Spider-Man code so that chunk can generate the correct animations which then get combined back with the rest of the Batman game world state.
It certainly has some wild consequences for game preservation / availability - a recompiled Wolverine already 'runs' on PCs, albeit at single digit frame rates, but it still runs.