The crystal acts as a filter and coupling it with an inverting amplifier makes it an oscillator. At first, the inverter spits out noise. That noise is then filtered by the crystal and fed back to the amplifier. Let it ramp up and now you’ve got a stable oscillator a few ms later.
The crystals can be cut in different shapes for different frequencies and different angles for different temperature responses.
If you really want to get into the nitty gritty, Ramón Cera is a beast in the UFFC community and explains everything you need to know about crystals in his book Understanding Quarts Crystals and Oscillators. I use it just about every day to supplement my job.