The reason for this is very simple. You can only sink halfway, because the quicksand is twice as dense as the human body. It's actually also twice as dense as water, so it means that you float more easily in quicksand than you do in water.
Daniel Bonn took quicksand samples from Iran to figure out what it is actually made up of. He found that quicksand is made up of four key ingredients: sand, water, clay, and salt.
Together they create a structure much like a house of cards. There are large water filled gaps between the sand, which is loosely glued together by the clay. When the quicksand is left alone it is stable.
When the quicksand is disturbed by something stepping or falling into it, the consistency of the clay changes. It changes from a jelly-like consistency to a runny liquid.
By liquefying the clay, the quicksand as a whole becomes very runny and the whole thing collapses in on you. The sand then sinks to the bottom and the water floats to the top.
With enough salt present, when the clay liquefies, electrical charges make it stick together and make bigger particles. The particles then settle at the bottom with the sand.
This results in a very heavy layer of sand and clay that is twice as dense as the original quicksand. It is packed tightly around the trapped body part.