No, you cant just get the code of any app that’s in the appstore.
Most of this people just code their own version of this games, for example:
Flappy Bird, it has a really easy concept and not much gameplay so a good developer
could make a clone of that game in one day.
Another method is to buy the code of a game on one of the websites that sell code templates for apps and games.
solved How to make a clone of ios game? [closed]