Based on the protoplanet hypothesis, how did the earth end up being layered the way it is?
The original accretion created a uniform mixture of rock and iron. And then, as is often the case when you have a big thing, gravity took over ... see below.
Originally, the pieces that came together to make up the Earth were bits of rock and iron that were assembled randomly. The planet was primarily a uniform mixture of rock and iron.
But then the accumulated heat from gravitational compression and the still warm nebula caused these materials to melt. And when they did that they could flow in response to gravity. The iron-rich material, being denser, sank beneath the less dense rocky stuff that henceforth would be floating on top, a process called differentiation. A secondary differentiation has also occurred within the rock, bringing less dense minerals into the crust on top so that the crust and mantle have different compositions.
Differentiation has occurred in all terrestrial planets and even dwarf planets and some larger moons. Our own moon, for instance, is almost all rock but even this has a small iron core. There are also bodies where ice is differentiated from rock like Pluto, or even three layers consisting of an icy outer layer then the rock and an iron core. Jupiter's moons Europa and Ganymede seem to have that three layer structure, with some of the ice melted to a watery ocean beneath the surface.