Can we prevent metal corrosion by creating a vacuum around it?
The word corrosion has a range of meanings, but it is generally taken to indicate the chemical reaction of a material with its environment. For example iron corrodes by reacting with oxygen in the air (or water if it's underwater).

If you put the metal in a vacuum then it doesn't have anything around it to react with, so in this case yes putting the metal in a vacuum will stop it corroding.