So far the answer given limits itself to 8-bit PIC microelectronics, but the OP asked (in part):
Why are there different compilers when one can do the job?
Are certain compilers only used for specific microcontrollers?
I will answer both of these questions together. Microchip makes not only 8-bit microcontrollers (PIC10, PIC12, PIC16, PIC18) but also 16-bit (PIC24/dsPIC33) and 32-bit (PIC32).
Each of the 8-bit PIC's (except the PIC18) have similar instruction sets, using a single accumulator (W0), a small amount of RAM (25-256 bytes), and a hardware call stack. The instruction set originally had 35 instructions, but was expanded to 49 instructions on newer devices to better accommodate C compilers (Up to that point, most 8-PIC programs were written in assembler code -- many still are on the chips with very little flash.)
The PIC18 devices added support for a software stack, and a much large RAM. They have 75 instructions (83 for newer devices).
In spite of all these differences (particularly the differences between the low-end 8-bit PIC instruction set and the higher end PIC18), the XC8 compiler supports all of these 8-bit PIC families. It does so by actually making using of two compilers internally -- PICC and PICC18, and choosing which one to use based on the processor selected.
There are both free and paid versions of the XC8 compiler -- the only difference being the amount of optimization performed.
The next step up from the 8-bit PIC microcontrollers are the 16-bit PIC24 and the dsPIC33. These are very similar -- the dsPIC includes the PIC24 instruction set, but also adds additional instructions for doing DSP (Digital Signal Processing), hence its name. These 16-bit PIC processors are supported by the XC16 compiler. Although they can be programmed in assembly language, it is seldom done except for very tight loops or time critical interrupt service routines (ISR).
Like XC8, there are both free and paid versions of the XC16 compiler -- again the difference being the amount of optimization performed.
And finally, there is the 32-bit PIC32 family, with an instruction set derived from the RISC-style MIPS. The newer devices can address up to 2MB of flash memory and 512K of data. The 32-bit processors are supported by the XC32 compiler. Like the PIC24, they are seldom programmed in assembly language. And also like Like XC16 compiler, there are both free and paid versions of the XC32 compiler -- again the difference being the amount of optimization performed -- some as much as 50%.