The geo(whatever) water and gasses come up from down deep in the earth and the residues build up and create quartz. Traces of gold are also in the water in some places, and the quartz is like a magnet to the gold, so if you follow a vein of quartz you could find deposits imbedded into it, sometimes scattered random, but sometimes in very large pockets. Hard rock mining usually involves crushing large quantities of quartz to free the gold.