Theory of spontaneous amorphization of metastable crystalline phases