How does a rock transform into a crystal?
user
Aren’t you really asking how a rock transforms into a diamond?
assistant
Yes, or how any other rock turns into something like quartz.
user
Quartz is a form of crystal.  Most crystals are silicate minerals, and the way they form is quite interesting.  The main thing that changes when a rock becomes a crystal is its atomic structure.  A rock is a solid, made of a large number of atoms of a single type (mostly silicate) that have electrical charges on them.  In the case of silicate crystals, there are two common structures:  One type is when the atoms are arranged into a rectangular lattice.  The other type is where they are arranged into a more complex network.  Rocks typically have a lattice structure, which is why they can be cut and shaped.   The atoms in crystals have more complicated arrangements of charges, which are more difficult to shape, and require much more energy.   The energy comes from the chemical energy in the water or other mineral, which is needed to melt and re-arrange the structure.  That energy is released when the crystal is made, and if the energy is released gradually it’s called a “thermal process” and if it’s released suddenly it’s called an “explosive process”.
assistant
How is it melted and re-arranged?
user
It’s not always entirely clear what causes the sudden release of energy, but there are some common hypotheses.  These include “stress” on the atoms, when the atoms are in a different arrangement than the typical lattice, and high temperature, which means the atoms move more freely, are likely to rearrange their positions, and have more energy.  However, some researchers think that there may be new internal crystalline energy states, which the crystal tries to escape from.
assistant
How many years ago were crystals like these created?
user
We don’t know much about that, but we do know that they’ve been forming for a long time.  The Earth itself is thought to be around 4.6 billion years old.  Crystals don’t survive over time in the Earth’s crust, but they do survive in ancient rocks that have been buried under the surface for a long time, and can be found in places like the Western United States.  Most of the crystals have probably formed since then.
assistant
How does a rock transform into a crystal?
user
Aren’t you really asking how a rock transforms into a diamond?
assistant
Yes, or how any other rock turns into something like quartz.
user
Quartz is a form of crystal.  Most crystals are silicate minerals, and the way they form is quite interesting.  The main thing that changes when a rock becomes a crystal is its atomic structure.  A rock is a solid, made of a large number of atoms of a single type (mostly silicate) that have electrical charges on them.  In the case of silicate crystals, there are two common structures:  One type is when the atoms are arranged into a rectangular lattice.  The other type is where they are arranged into a more complex network.  Rocks typically have a lattice structure, which is why they can be cut and shaped.   The atoms in crystals have more complicated arrangements of charges, which are more difficult to shape, and require much more energy.   The energy comes from the chemical energy in the water or other mineral, which is needed to melt and re-arrange the structure.  That energy is released when the crystal is made, and if the energy is released gradually it’s called a “thermal process” and if it’s released suddenly it’s called an “explosive process”.
assistant
How is it melted and re-arranged?
user
It’s not always entirely clear what causes the sudden release of energy, but there are some common hypotheses.  These include “stress” on the atoms, when the atoms are in a different arrangement than the typical lattice, and high temperature, which means the atoms move more freely, are likely to rearrange their positions, and have more energy.  However, some researchers think that there may be new internal crystalline energy states, which the crystal tries to escape from.
assistant
How many years ago were crystals like these created?
user
If by “created” you mean they formed spontaneously from other materials, there are records of crystalline rocks as old as 3.5 billion years.  Many crystalline rocks were formed only in the last 400 million years, which is relatively recently compared to the age of the Earth, which is about 4.5 billion years.  The oldest gemstone on Earth is the 2.1 billion year old Ural Mountain Garnet.
assistant
How does a rock transform into a crystal?