These are known as console commands and are pretty universal in video games. These allow developers to troubleshoot their game without necessarily quitting the game and going into their source code.
In GTA5 specifically these console commands have actually been made pretty limited. They only allow the player to spawn items and change minor gameplay attributes. During development it would have allowed the user to teleport anywhere, load anything, or change other important features of gameplay.
Before release the usage of the console must have been restricted to spawning a limited number of items, and disabled entirely in GTA: Online.
While these are cheats, it is not implemented by a third party hacker.