Why do mineral ore deposits occur?

The origin of stuff like limestone, coal, and organic phosphate deposits is pretty clear, but why do we find concentrations of ores like iron ore, copper, aluminium, gold, uranium, etc? They’ve been there since the origin of the Earth, so what caused them to coalesce? Why are they there and not just mixed in the the crust?

WAG

they solidify at a certain temp, so when a section is cooling that is what comes out of the liquid