Gems are formed from silicon and oxygen in the atom size in six sized prisms forming together. it is said that quartz help form the other crystal. but each crystal has their own requirements to become gems.
diamonds are formed from carben in its purest form. the heat and pressure from the mantel and crust of the earth creates the diamonds and magma channels carry them up to the surface. The pressur and heat from the gas planets can create diamands easser
We also can create man made gems from paint on machine and in labs. Such as a type of gem that is mostly a dark blue and is never clear is made from paint on factory machine.