Why does the grated coconut "float" to the top of quindim while baking? Quindim is a typical Brazilian dessert made from sugar, egg yolks, butter and grated coconut.

All those ingredients are mixed (yolks and sugar first, then the butter, then the grated coconut, in my experience), then bain-marie baked in a pudding mold or in muffin tray slots. And, somehow, the grated coconut is all at the top (which ends being the bottom) of the mixture at the end of the baking process.

Also, I've read that the quindim's ancestor recipe from Portugal, brisas do Lis, exhibits a similar phenomenon, where small almond pieces float to the top of the mixture while baking.

What causes the grated coconut or the almond pieces to move to the top of the mixture during the baking process? Does this occur in other recipes (maybe in less noticeable ways)?

(My ultimate point is to know how to cause such an effect in similar recipes.)
While the mixture is raw, the density of the batter is more or less equivalent to the density of the grated coconut, and the batter is fluid, allowing movement.

During cooking, the egg protein in the batter denatures and coagulates, generating a dense colloidal matrix that doesn't allow movement. As this process is happening, the proteins are aggregating to themselves and pushing the coconut to the top (it is pushed up since it is less dense than the newly-forming colloid). 

A similar phenomenon happens with you put raisins, other dried fruit in batter (like in fruit cake or panettone), but they are pushed DOWN instead of up. Coating them in flour prevents them from sinking not because of the change in density, but because it gives anchoring points to the matrix to form around the fruit instead of pushing it.