Sometimes they're used for debugging purposes and just left in (such as any PC game with a console command available), other times they're intentionally made as cheats (such as games with a specific 'Cheats' menu or button combinations). Just depends on the game.