What does saturation do in Minecraft? I know some foods have, like, 5 saturation or 12 saturation, but what does saturation mean? Is it how fast the hunger bar stays full, or is it like a hidden mechanic?
Saturation is, as you were thinking, a hidden mechanic similar to the hunger bar, as well as a status effect as Pan V answered.
Each food type has a saturation value that, when eaten, will add to the player's current saturation (the maximum saturation you can have is equal to your current hunger level, so if 7 hunger icons are filled, you have 14 hunger points and a maximum of 14 saturation points). As long as you have a saturation value greater than 0, the player's hunger bar cannot drain, although once your saturation has reached 0, the hunger bar will begin playing a slight bouncing animation and can be drained. Saturation will always be depleted before hunger allowing the player to sprint and regenerate health for a short time after eating before the hunger bar begins to drain again.
For a complete list of all foods and their saturation values and actions that naturally deplete the hunger and saturation, see https://minecraft.wiki/w/Hunger
Saturation is a hidden mechanic, like you said, but also works similar to the hunger bar. When you eat something, your saturation goes up. But it goes down similar to the hunger bar. Different foods have different saturation, and if I am not mistaken, it cannot be added to itself. As far as I know, the Golden Carrot gives the most saturation, allowing you to sprint jump for a long time without having to eat again.
The saturation bar acts the same way as the hunger bar. It goes down at the same speed your hunger does. So doing stuff like sprint jumping or mining for extended periods of time will deplete the saturation bar. When the bar reaches 0, your hunger will go down normally. As far as I know, there is no way to see your saturation bar or make the game show you how much saturation you have left.