A compiler reads your C++ code and translates it into machine code your processor executes. You write cout << "Hi"; and the compiler converts it to binary instructions. Compilation happens before execution.
When you click run, the compiler checks for errors, translates valid code, then runs the program. Different compilers exist but they follow the same C++ standard. Code that compiles with GCC also compiles with Clang or MSVC.