For ex: Two machines have the same compiler and the same operating system. But the two machines have different processors (different assembly instructions).As the compiler was downloaded with respect to the operating system, how does the source code get converted to machine language of each processor?
Essentially, through configuration options.
A compiler that understands multiple back-ends will usually assume that source code should be compiled to the platform (os + processor type) on which the compiler itself is running. Everything else would be cross-compiling, and would have to be specified via command-line switches or configuration files.
You use different compilers.
The GCC compiler for ARM is different from the GCC compiled for x86. They may share the same source but once they're compiled they become two different programs, different compilers.
You have different steps,
For example you're working on an x86, you can compile your compiler to run on x86, but you can also compile it to run on ARM.
And once you have your compiler running on ARM you can run it to output ARM-programs, but also to output x86-programs.