Why do sedimentary rocks have layers?
Sedimentary rocks have layers because of different depositions of sediments (small broken pieces of rocks) over time. The different groups of sediments could have been deposited through wind, water, ice, and/or gravity at different intervals of time and compacted on top of each other, until they create a sedimentary rock that has several different types of sediments (possibly from different rock types) in the form of layers.
You can think about it this way. Imagine you have some dirt, sugar, and sand in different containers. These are your "sediments". You get a large clear boc, and dump in all of your dirt. That is your first (and oldest!) layer. Then, you dump in all of your sugar. That is your second, middle layer. Then, you dump in your sand. That is your third, newest layer. If you look at the clear box, you will see that you have a dark brown bottom layer, a white middle layer, and a sandy beige top layer.
To relate this to rocks, the "dumping" of rocks is done through erosion. Eventually, after lots of time and pressure, the sediments compact together and form layers that eventually form a rock.