Digestive system does not really know what to break or digest. Different secretions from digestive glands break different parts of food. For example
1. In the buccal cavity, salivary gland secretes ptyalin enzyme that partially starts the breakdown of carbohydrates.
2. In the stomach, pepsin partially breaks proteins to peptones and gastric lipase breaks down fats partially.
3.Bile from liver carries out emulsification of fat.
4. Protease (trypsin), carbohydrase and lipase present in intestinal and pancreatic juice cause complete breakdown of proteins, carbohydrates and fats into amino acids, maltase and fatty acids and glycerol respectively.
The digestive system does not pick, choose and refuse the food items that are broken down in the body or merely excreted. It breaks down all the digestible components of ingested food items through enzyme-catalyzed reactions. Three of the main components of food items that are digested (broken down by enzymes) into simpler molecules that the body can absorb are carbohydrates/starch (converted to maltose), proteins (converted to amino acids) and fats (fatty acid and glycerol).
The enzymes in the body and digestive system are very specific. Picture a jigsaw puzzle piece fitting in a puzzle space with a similarly shaped open slot as the shape of the puzzle piece (see the attached picture below). The same principle applies to enzymes and their particular substrate. For instance, the fat molecules only bind to lipase, not maltase or peptidase, and are broken down to form fatty acids and glycerol. One food component not completely broken down due to the body's inability to produce cellulase is fiber, which, for the most part, is excreted almost unchanged.
The whole process of digestion is fully explained at the attached link.