Fertilizers are made of several different compounds. Keep in mind that organic fertilizer (often called manure) is an animal byproduct whereas other fertilizers consist of a variety of inorganic compounds. In general, these are both a concentrated form of the nutrients a plant needs to survive, much like a vitamins. This plant "food" often contains relatively significant amounts of the three most important plant nutrients: Nitrogen, Phosphorous and Potassium. While nitrogen is available in the atmosphere, remember that it is in the stable gas form, N2. In order to be biologically useful, the atomic, or elemental, electrical properties of the electrons are needed. The same follows for P and K.
Nitrogen is most commonly associated with fertilizers and is, arguably, of the most importance. However, Nitrogen is considered relatively active in this electronically (for lack of a better word) "unstable" condition. It is relatively common knowledge that fertilizers can be used for making explosives, as have several uni-bomber-style occasions in the past. This is due, specifically, to this electrical configuration. For this very same reason, Nitrogen's electrical properties allow for relatively low-energy reactions within cells. This is the same reason humans need vitamins and nutrients for things such as ATP usage, the electron transfer chain, and Calcium in the contraction of muscles and other intracellular communication. In fact, humans use a great deal of Nitrogen on a daily basis, which is excreted from the body in the form or Urea (hence, urine). Urea is a Nitrogen-based compound that offers partially stabilized electron configuration, and is then safe to pass through the body. Usually, the reactivity of Nitrogen is utilized in complete cellular destruction, as is the case of Ammonia. In order to prevent damage to cells not involved in the important, previously mentioned reactions, the body converts this to Urea.
Finally, there are several other key elements to the survival of a plant, including: Calcium, magnesium and sulfur. Several other somewhat less-important nutrients (sometimes called micronutrients due to the small amounts needed or present) are: iron (known for restoring "green" to yellowed or dull leaves), copper, zinc, molydebnum, etc. Also, in an attempt to further explain the electrical properties of nitrogen, it may be important to realize why over-fertilization kills plants. This can be, in very general terms, related to the similar properties of Nitrogen to compounds like Sodium and Chlorine. Sodium is a metal that combusts on contact with moisture and chlorine is a painfull and deadly gas. Together they form salt (an ionic compound with slightly positive and negative polar points) which humans and many other plants and animals would die without. However, salts are very weakly acidic (due to the small excess of negative charges), which is why urine will rust metal and eat away at paint and stains, over time. When the Nitrogen-containing fertilizer contacts water (or is utilized), it equilibrates (partitions) into its respective species. Nitrogen contains the extra lone pair of electrons, which is a partially negative charge, leading to the same properties as salts (which dehydrate cells) and acids (which kill plants). This can become a serious problem when the leaves seem to "dissolve" or "eat away" into thin air, turn yellow and curly, or the roots seem to shrink (dehydration, often identified by small wrinkles on the outer circumference of a root rather than smooth white tubes).
I hope this helps with the understanding of how and why fertilizers work. For more specific information regarding the reactions mentioned which are important to plants and animals, try to research "mechanism" for the related reaction (electron tansfer chain, ATP chain, the Nitrogen cycle, etc.)