The cottage loaf sign occurs as a result of a right-sided diaphragmatic rupture with partial herniation of the liver through the diaphragmatic defect.