What information is useful for predicting whether metal will replace another metal in a compound?
Its place in the reactivity series (also called the activity series of metals).
The reactivity series, shown above, orders metals from the most to the least reactive.
If a compound with a relatively unreactive metal like silver, is reacted with a more reactive metal, like magnesium, then the magnesium will displace silver because it has a stronger claim to the compound.
Magnesium displaces the silver in the nitrate compound because it is more reactive, so forces the silver out of its place.
It is the same process for any metals. If one is higher than the other in the series, it will displace it in a compound.
Carbon and hydrogen are added in, even though they aren't metals, for comparison.