The truth about this is that all across the earth's surface there is gravity. So what happens is that sediments will deposit parrele on Earth's surface which is horizontal. Basicaly explained, As more sediment is added, it is compressed and then it is hardened into rock layers.