Diarrhea can occur due to various factors, including viral or bacterial infections, food intolerances, or consuming contaminated food or water. Stress and certain medications can also contribute to its onset. Maintaining good hygiene, such as washing hands and ensuring food safety, can help prevent diarrhea. If symptoms persist or are severe, it's important to consult a healthcare professional.