Here's my explanations of how hacking works (not sure if accurate)
Do you play Pokemon Showdown? If you do, then you know there's an import/export button. When you click it, it shows text. If you edit the text, it's sorta like hacking but not quite.
Another example which is more related to programs and games still uses text, but is more complicated. Basically, when you open a JSON file from the program with a text editor, you see confusing scripts all over the place. Depending on the program and JSON your hacking, it will show different things. In Minecraft Files, you can find the AI and behavior of the entities, which you can edit and 'mod'. That's how people mod Minecraft.