Rust is made when oxygen mixes with air then the iron reacts with the water, the iron becomes hydrated and rust is made.

How could you prevent something from rusting?

You can prevent rust by painting iron you can also prevent painting iron. For example A bike if you leave a bike in the rain it will rust, but if you paint it won't rust. What about the chain it's really difficult to paint you can just oil it and that also prevent rust.