The body metabolizes fats into carbon dioxide and water, but when carbohydrates are insufficient or their metabolism is impaired, fatty acids are broken down, producing ketones. These ketones (acetoacetic acid, acetone, and beta-hydroxybutyric acid) are excreted in urine. In untreated or poorly managed diabetes mellitus, the body metabolizes excess fatty acids due to inadequate insulin, leading to ketonuria.