Color happens in the mind. Light has a mix of wavelengths, but it doesn't have color until you see it.
The color you see is determined by the wavelengths in the light that reaches your eyes. And that is determined by the wavelengths you start with and which wavelength are absorbed by reflection.
You see white from a mix of all wavelengths. Red is from just the longer wavelengths. Blue is from just the shorter wavelengths.
You shine white light on an object. Suppose it absorbs short wavelengths and reflects long wavelengths. Now all that is left is long wavelengths. You see red. We say that an object like this is red. It turns white light red.
Suppose you shine blue light on that object. It absorbs the short wavelengths, leaving nothing. It looks black under blue light. We still say it is a red object. The color of an object is determined by its reflectance properties.
This is a simplified picture. We have three types of color receptors in the eye. They are broadly sensitive to short, medium, and long wavelengths, though there is a lot of overlap. Light with just one medium wavelength will stimulate all three receptors, but mostly the middle one.
Light with a mix of long wavelengths will stimulate the long wavelength receptors most. This makes us see red. Other mixes stimulate the receptors differently. The mix of stimulation is how we see all the colors.
There are 3 primary colors because we have 3 types of receptor.