Both air and water are necessary for iron to rust, which refers to the corrosion of iron
Experiments can show that both are required by putting iron in four environments: oil to remove air & water, air with calcium chloride to remove water, boiled water under a layer of oil to remove air and partially submerged in water; only the partially submerged nail rusts
Prevention
Most methods are based on the exclusion of air & water
Coating the iron, in grease, oil, paint or plastic, prevents air & water from coming into contact with the iron
Sacrificial protection the connection of iron to a more reactive metal that will donate its electrons to any iron ions that form and get preferentially oxidised