During heating some amount of water gets converted into vapour and the bubbles of water vapour rise to the top The vapour gets trapped in the creamy upper layer. As the milk is heated further the water vapour expands and thick foam is produced on the top.
As the milk is boiled continuously the water, which boils at 100 degrees Centigrade, produces more water vapour and pressure builds up in the boiling milk so that the vapour pressure raises the creamy layer. So the milk pushes the creamy layer out and milk spills out.