In children, toxic megacolon can be caused by a variety of factors including inflammatory bowel disease (IBD), infections like Clostridium difficile, and other conditions like Hirschsprung's disease. These underlying conditions lead to inflammation and damage to the colonic wall, resulting in its dilation and loss of muscle tone.