Sweat is produced by two different glands. Eccrine glands cover most of the body and produce sweat primarily consisting of electrolytes and water, which cools the body when it evaporates from the skin.
Apocrine glands are found in the groin, hands, feet and underarms. These glands produce sweat that contains proteins and fatty acids, which makes the perspiration thicker and milky or yellowish in color. This is where the sweat stains you see on light-colored shirts come from. While eccrine glands are activated as part of the body's cooling system, apocrine glands can produce sweat when the body is experiencing anxiety, nervousness or stress.
When it first emerges on our skin, sweat is just a fluid without an odor. However, the bacteria on our bodies are particularly attracted to the proteins in apocrine sweat which they eat, digest and expel as highly-aromatic fatty acids. These include the notorious (and notoriously named) (E)-3-methyl-2-hexenoic acid. The process typically takes about an hour.
It doesn't help that the apocrine glands are found in the moist, dark areas of the body -- exactly the neighborhoods in which odor-producing bacteria like micrococci and staphylococci enjoy living. When we wrap our feet in socks and leather shoes, we not only create a haven for bacteria, but for fungi as well, which is why our foot odor can be particularly troublesome and different in character from underarm smells.
Our apocrine glands do not become active until we reach puberty, which is why babies smell sweet -- teenagers, not so much.
Not only are there differences between first-graders and high school seniors in terms of body odor, there are also disparities between men and women and even between members of different races, as we'll see in the next section.