Well thats kind of vague. Compilers turn the readable code u recognize (like c or java) into machine code. Java is a bit interesting in that theres an intermediate step but u can read on that later.
Basically lets say I have hello world program in C. If I compile it using an x86 compiler, itll turn it into machine code for an x86 machine. If I use an ARMv7 compiler, itll run on an ARMv7 machine and not on x86 machines. In this way, we can write cross platform code which just needs to be recompiled instead of rewritten to run on many different architectures. Do note that not all x86 compilers are created equal. Some are more optimized for things others. Also, sometimes u run into commands specific for ARM that dont run on x86 at which point u have to rewrite small parts of ur c code.