Since 1825 or so, canning has provided a way for people to store foods for extremely long periods of time. In canning, you boil the food in the can to kill all the bacteria and seal the can (either before or while the food is boiling) to prevent any new bacteria from getting in. Since the food in the can is completely sterile, it does not spoil. Once you open the can, bacteria enter and begin attacking the food, so you have to "refrigerate the contents after opening" (you see that label on all sorts of food products -- it means that the contents are sterile until you open the container).
We generally think of "cans" as being metal, but any sealable container can serve as a can. Glass jars, for example, can be boiled and sealed. So can foil or plastic pouches and boxes. Milk in a box that you can store on the shelf is "canned" milk. The milk inside the box is made sterile (using ultra high temperature (UHT) pasteurization) and sealed inside the box, so it does not spoil even at room temperature.
One problem with canning, and the reason why refrigeration or freezing is preferred to canning, is that the act of boiling food in the can generally changes its taste and texture (as well as its nutritional content).