Exposure Metering Modes
Your camera contains an incredibly accurate and also incredibly clever light meter that does all this measuring of brightness for you.
The computer in your camera will look at the scene and not only measure the total amount of light, but can also determine what TYPE of scene it is, i.e. a landscape, a person etc., and adjust accordingly.
For example, if it recognises a human head against a bright sky it knows you want the face exposed correctly, even if that means the sky is going to be too bright. This computer is nothing like as sophisticated as your eye/brain combination but it is remarkable how often it will get it right first time.
However, if the camera does not match the scene in its "library" of scene types then it will normally just try to make an average of all the light and do its best.