Sedimentary rocks are formed by the accumulation of sediment over time, which is then compacted and cemented together.