A magnet has two poles - north pole and south pole. All the atoms or molecules of a magnet are aligned themselves throughout the substance in one direction. Thus there is a magnetic dipole moment, of the magnet, that creates a magnetic field around it.
The magnetic field induces magnetism inside the substances like iron. The atoms align themselves quickly along the direction of magnetic field lines. Hence, they develop a dipole moment in the opposite direction.
Near the magnetic north pole of the magnet, south pole of Iron piece is developed. Hence it is attracted.
For other metals, they do not have magnetic properties as much as iron and the atoms do not align themselves along or opposite the field of magnet. The atoms of other metals still are oriented in random directions, hence there is no net magnetic effect.