Products with a short shelf life are frequently dated to be sure that spoiled products are not sold. Grocery stores use the dates to rotate stock on and off of the shelves.
Products with fats are slowly air oxidized forming compound with a rancid (bitter) taste. Butter, oils, nuts, and many other fat products that are open to the air must be used before the rancid taste is apparent. Milk products are dated because enzyme reactions or bacterial reactions may change the product. Milk is said to sour as the proteins in the milk react. Some sweetners (aspartame) in diet drinks react slowly in the acid solutions in carbonated beverages leaving behind a bland liquid.
Any processes that slow the reaction help to preserve the product.