The first and most common way is to enter the cheat codes in console games. To open the console, you need to visit the settings of the game. Perhaps that's where you have to tick the options "Open console developers" or assign a specific key to open it (usually it is a button "~"). Once you can open the console to enter a cheat code.
If the game does not provide a console then you can enter the cheat codes, reproducing a sequence of letters or numbers from memory. In some games you need to enter the cheat codes in the main menu or sections, others already in the game.
The most difficult way is to change the configuration files or files saved in the root folder of the game. Often this may require special programs. This method allows you to change almost any parameter or variable in the game.
Some games third party developers to create a special program, "trainers" - a set of cheat codes. In order to use specific code in it, you need to press a specific key combination.