An RGB LED is a combination of 3 LEDs in just one package:
1x Red LED ; 1x Green LED ; 1x Blue LED
The color produced by the RGB LED is a combination of the colors of each one of these three LEDs.
How to create different colors?
You can create one of those three colors – red, green or blue – by activating just one LED.
For example, if you want to produce blue, you activate the blue LED and turn off the other two.
To produce other colors, you can combine the three colors in different intensities. To generate different colors you can use PWM to adjust the brightness of each LED.
As the LEDs are very close to each other, we can only see the final colors result rather than the three colors individually.