Although I don’t know if these games are using the same code, I have seen it happen with other games. I think what happens is, an outsourced company is tasked with creating a game, however the contract for creating the game may not be exclusive. Or it may be exclusive for 1 year only. So after such time, the creators of the game can sell their code to another buyer. This buyer may change small parts of it and re-use it.
Another possibility is an employee steals the code and attempts to sell it to another company, without the buyer knowing that it is copyrighted.