The magnetic domains in the 1018 steel easily align with the applied magnetic field. The domains on each side of steel cube align with the magnetic field at that side. Thus both magnets form attractive forces with the steel. Any material with easily rotated magnetic domains will work.