The processes by which loose sediment is hardened to rock are collectively called LITHIFICATION.  Once this happens, continued erosion and re-transport of the sediment become much more difficult.  There are three basic ways that lithification is accomplished.

One way to harden sediment is simple COMPACTION, but this only works for some types of very fine sediment.  Coarser sediment particles usually do not lithify in this way because getting them closer does nothing to cause them to "stick".  Clay minerals are different, however.  These tiny particles are very much like miniscule, plate-shaped mica grains, and like micas they have slight electrical charges on their surfaces.  Pressing them together, particularly if it involves rotating them such that their flat surfaces come into contact, allows them to establish attractions for each other very much like Van der Waals bonds.  The electrical charges tend to make them adhere to each other.  As with Van der Waals bonds, however, the attraction is not terribly strong, and sediments lithified in this way are generally not particularly resistant to subsequent erosion.

A second natural method of lithifying sediment is by RECRYSTALLIZATION of some or all of the constituent minerals.  Limestones and other chemical sedimentary rocks are most susceptible to this process because their minerals are fairly easy to modify in surface environments.  Much natural CaCO3 in the Earth's ocean is not calcite but a different mineral called "aragonite".  Aragonite takes up less volume per molecule than calcite.  It is not really stable in fresh water, so once rainwater comes into contact with it, it changes into calcite.  The crystals grow larger because of this transformation and tend to mesh themselves together as they do so.  This locks the particles together, making the entire structure stronger and harder.

The most common method of lithifying coarse grained sediments is by CEMENTATION.  Sedimentary particles are deposited in contact with each other, but there is also a certain amount of empty space in a pile of sediment.  As water carrying dissolved ions fills in that empty space, the ions may crystallize new minerals between the grains.  In the process of growth these newly forming crystals become enmeshed with each other, as we saw in recrystallization, and the result is once again a more cohesive, harder mass that the original loose sediment.

Quartz cement is quite common in nature, and tends to make the hardest rocks.  Calcite and hematite are also rather common, but tend not to lithify the rock as tightly.  Halite and gypsum cements occur in some special environments, but they are poor cementing agents.  Many other minerals are known to act as cements; all but the few mentioned above are quite rare.