Oxygen present in water and salt causes corrosion. Salt is hygroscopic in nature and it attracts the water. Water is required for corrosion and salt speeds up the process.
Corrosion is the transfer of electrons from one substance to the other so salt present in water improves the capability of water to carry electron through redox reactions. Redox reactions are the oxidation and reduction reactions. In oxidation a particular substance loses electrons and in reduction a substance gains electrons which are released by the oxidation. When these both reactions took place it is known as redox (Reduction and Oxidation) reaction.
Rusting in metals is the oxidizing of metal to metal oxide. Water acts as the medium to transfer the electrons and salt helps the corrosion process to speed up the process. It is an electrochemical process in which iron loses electrons by oxidation causing the water to break into hydroxide ions and oxygen. Now the iron that has oxidized reacts with the hydroxide ions and oxygen to form metal oxide. These salts remain even if the water is gone and they again start rusting whenever they come in contact with moisture. That is the reason why the metals get rusted more quickly near the beaches or salty places.