What is the science behind Magic Cake?
In case you are interested, the magic comes at least partly from the milk.
I accidentally forgot to add it (but other than that, I followed the recipe to the letter), and I ended up with a regular vanilla cake, no layers at all.
I imagine this cake part should've been the (partly) the upper layer.

As milk is heavier than some of the other ingredients, it sinks to the bottom and creates the custard layer. I would like to expand this answer, with a remark on what we call 'flantaart', translated as 'custard pie'. There is one batter, and after baking, a well defined crust and a custard on top. I'll look it up when I get home, to look for similarities between the two recipes.