Onions are bulbs, a modified version of a stem. The layers however, are modified leaves of the onion. A bulb is formed from a growing bud in the center of the plant from which new leaves emerge. These leaves are formed as a protective barrier in case an animal tries to eat the plant. In order to destroy the plant the animal would have to get through layers of outer leaf which tastes nasty. Also the leaves of an onion serve for food storage.