Why do objects appear the color they are?

It's a matter of selective absorption and reflection of the varying wavelengths of light. Our eyes and brain work together to interpret the different wavelengths of light as different colors. White light is composed of all possible wavelengths of visible light, and sunlight is very nearly white. Characteristics of various surfaces cause them to reflect or absorb certain wavelengths. The ones that are reflected to our eyes are what determine the color we perceive. To cite just a single example, if a ball is red, it reflects red light and absorbs the other colors. That's why it appears red. The issue is slightly different for a source of light, and the answer speaks to all other things we see and the colors they appear to have.