If you had pure iron, and put it into pure water, very little would happen, since there would be no oxygen to react with the iron. But if you put the pure iron into pure dry oxygen, very little would also happen. The outer iron atoms would rust, but then that layer of rust would stand between the iron and the remaining oxygen.
Water helps iron react with oxygen. The first step in getting oxygen to react with iron is to break up the oxygen molecule. In water, oxygen can steal some electrons from iron to make four hydroxyl ions (the OH- ions in the following reaction):
O2 + 4 e- + 2 H2O → 4 OH-
The electrons come from the iron:
Fe → Fe2+ + 2 e-
But to make rust we need another reaction with iron:
4 Fe2+ + O2 → 4 Fe3+ + 2 O2-
In the process of making rust, the ferrous (Fe2+) and ferric (Fe3+) ions also react with water to form Fe(OH)2 and Fe(OH)3 (ferrous hydroxide and ferric hydroxide) and hydrogen. These hydroxides can then lose their water to form still more iron compounds. It is all these reactions that end up making the rust flaky, so it falls off the iron and exposes new iron that can start to rust.
All of these reactions are sped up by acids and by having more ions in the water, so it conducts electricity better, so that the iron and oxygen can exchange electrons.
Adding salt to the water makes the iron corrode more quickly, but adding an acid makes it corrode even faster than that.