Metals corrode more quickly near the sea due to the water content in the air and the presence of salt. Metal atoms can react with other elements, becoming charged. When they become charged, they are attracted to water molecules and subsequently dissolve. Salt's electrolyte characteristics speed up the process.
Corrosion occurs when metal atoms react with their environment. Rusting is a common form of corrosion, created when iron reacts with oxygen molecules to form iron oxide. Metals also react with other compounds in the environment, either picking up or losing electrons. Once metal atoms are charged, they become more attracted to polar molecules like water than they are to nearby metal atoms, and they can be pulled away.
Salt water speeds this process by forming an electrolyte solution. Much in the same way an electrolyte in a battery facilitates the movement of electrons from one electrode to another, immersing any metal in an electrolyte solution speeds up the movement of electrons and the process of corrosion. Metal does not even have to be fully immersed for this process to take place, as increased humidity and salt spray can provide the necessary electrolyte contacts for corrosion.
Different metals corrode at different rates, and the presence of a material that corrodes easily may protect harder metals. For instance, an aluminum plate near an iron propeller shaft may attract more electrons, corroding faster and preventing damage to the more valuable piece of machinery.