You follow the sequence exactly as the code specifies — for example, Up, Down, Start, and so on.
There is an important distinction hiding inside that, though. The GBA itself has no cheat system. Built-in codes like the ones you enter on a title screen are actually part of the game, and the console is only passing your button presses through. That is why they are entered at a specific moment, usually during the boot sequence or on a menu, and why getting the timing wrong produces nothing.
True cheats — the kind that alter memory, give unlimited items, or bypass content — require a third-party device such as an Action Replay or GameShark cartridge inserted alongside the game. Those work by modifying values in RAM as the game runs, which the stock hardware cannot do.
So if a code is a button sequence, enter it precisely and in the right place. If it is a string of characters and numbers, you need a cheat cartridge, and no amount of button-pressing will substitute.