In those rocks where a pathway from a source rock to the host rock occurs and on the way trapping physical-chemical conditions become more and more favorable in space and time for the elements in question .
This is the simplest way of ore accumulation.
It is temperature, pressure, Eh and pH changes that count.
You can use this construct for each and every commodity.