The answer is as varied as the many different models of cameras and their related firmware.
When set to AWB, most older digital cameras use algorithms that attempt to set white balance based on the assumption that the brightest areas in the frame should be neutral white or very light gray. This works fairly well unless some areas are fully saturated in all three channels (before any exposure adjustments are applied).
The result may be similar to one of the preset selections available (Daylight, Tungsten, Cloudy, Fluorescent, etc.) or it may be considerably different from any of them. If the detected scene is close enough to one of the camera's preset choices, that one might be applied or might not, depending upon the exact camera model in question.
Newer cameras often use more sophisticated algorithms that can vary greatly from one camera model to the next. Most are similar to some forms of metering such as Nikon's 'Matrix' or Canon's 'Evaluative' metering in which the data from the frame is compared to a library loaded into the camera's firmware and applied based on instructions for the closest match. If the camera detects a scene with bright blue sky in the upper part of the frame and darker green in the lower frame it will apply WB based upon a landscape profile. If it detects a scene with lots of areas that look (to it) like skin tones it will apply a WB based upon a portrait profile. (This explanation is vastly simplified from the many subtleties that are analyzed and can affect the outcome.)
Some cameras even allow user selectable options between bias towards the brightest areas of the scene or bias towards the more average areas of the scene. Canon calls the two choices available with some of their newest models 'white priority AWB' or 'ambience priority AWB'.