Magnets create a magnetic field that attracts certain metals like iron, nickel, and cobalt, and repels other magnets. An example is an iron nail being pulled toward a horseshoe magnet when entering its magnetic field due to the nail's ability to be magnetized by metals.