Lithification is the process by which sediment turns into hardened rock. There are three ways in which lithification can occur. These processes are called compaction, recrystallization and cementation
so sediments (sand) are buried the increase in pressure from the weight of the overlaying material pushes the grains closer together. the volume of sediment is reduced and the fluids between the grains are also squeezed out. this leaves the sandstone tightly compressed together this is lithification.