The answer to this is fairly complex, and is often dependent upon features and hardware specific to camera brands and models, as well as the camera exposure settings chosen by the user. To keep it simple, what the camera "sees" and what it decides to expose is dependent upon light metering. Modern cameras have sophisticated metering devices built into them that measure the light coming through the lens. Depending on how you have your camera configured, the camera will use the metered light value(s) to set aperture, shutter, and possibly ISO. When a scene is properly metered, a camera in fully automatic mode will usually choose correct exposure settings, however some scenes need more care and attention when metering to assist the camera in its choices.
Metering in most cameras is based on the ANSI standard value of "12% gray". This value is considered to be the "middle tone" between pure black and pure white in terms of luminance (light from a light source that is reflected off a scene or object in a scene). This means that the meter takes the average level of luminance of the area metered, and assumes the average is 12% gray. For scenes that cover a wide range of tones, from deep blacks through middle grays to bright highlights, this works quite well. For scenes that do not evenly span the range of tones, such as high-key or low-key scenes, the camera's meter may make an incorrect assumption about a scenes luminance, and measure 12% gray even if it should have metered a higher or lower value. Without careful metering with the camera, and use of the proper metering mode (more on this in a moment), such photographs often require black and/or white point selection during post-processing for correction.
Most DSLR cameras have a variety of metering modes. The default and most automatic is a form of evaluative metering, which meters a variety of areas in your scene and tries to apply an intelligent algorithm to arrive at a correct value. This often works great, but sometimes it does not work quite so well. Alternative modes include center-weighted, partial, and spot metering. These options measure progressively smaller areas, usually centered, although some cameras like Nikon allow spot metering around the currently selected auto-focus point. Spot metering is fairly precise, using only a very small percentage of the scene around the metered spot, to determine luminance. When using spot metering, it is best to point the camera at an area of the scene that is as close to "middle toned" as you can.
Not every metering mode works for every scene, and it is important to use the correct one. When manually setting exposure, it is often useful to use the camera's built-in meter in spot-metering mode to meter various parts of a scene to determine the real contrast (dynamic range) of the scene you are trying to photograph. This can be very helpful in helping you determine if you need filtration, or whether you need to adjust your lighting if you have artificially lit your scene. If you spend the time to learn how to use your camera meter in its various modes, you'll be more capable on a shoot or out in the field, and your scene contrast problems will eventually be a thing of the past.
Here are some useful articles on metering:
NOTE: Quite often, you may hear the
value "18% gray" used as the luminance
value that camera's meter at. Such a
value is generally inaccurate if you
wish to be precise, as 18% gray patch
is generally considered to reflect
half the light that reaches it. There
is no direct correlation between a
camera meters "12% gray luminance" and
prints "18% gray reflectance",
although I think generally speaking
they can be considered roughly
equivalent in their respective domains
(i.e. One would expect a photo of a
12% gray card should print 18% gray,
which when illuminated and
photographed should be correctly
metered at 12% gray again.) More
details on this here.