This is really a wide open question on which books could be written. First let's stipulate that we are considering aqueous solutions rather than say magma.
In aqueous solution the solubility of a particular mineral depends on the temperature, pressure and chemical composition of the liquid. Generally as a solution would rise towards the surface of the earth the pressure and temperature drop which tends to decrease the solubility. Once the solution becomes saturated with respect to a certain mineral then it becomes thermodynamically favorable for the mineral to deposit. However it is possible for a solution to become supersaturated.
Also you have to remember that homogeneous conditions wouldn't really exist. There would be temperature and pressure differences in water flowing through a crevice. The water wouldn't flow at a constant rate over long periods of time. So the whole aspect of deposition and dissolution would be very dynamic.
It is also possible to dissolve minerals A and B, yet deposit some mineral C.
Also for minerals there are often many different crystal formations. Calcite deposits in hundreds of different types of crystals.