OK: Muscles (and the rest of the body) need energy. That energy can come from several sources -- both stored and swallowed.
The blood and other body fluids contain enough blood sugar (glucose) to power the muscles for something like 15-30 minutes -- a relatively short time. After that blood sugar will begin to drop and the muscles must draw on other sources.
Glycogen is the next line of defense. The body stores glycogen (effectively a form of starch) in the muscles and the liver. When the muscles can't get enough sugar from the blood they will draw down their glycogen stores. In addition, the liver will convert glycogen to sugar and release it into the blood stream. I'm a little fuzzier on how long the glycogen stores are good for, but probably a couple of hours (though the more one trains on long rides, the more the muscles will build up their glycogen stores).
Next the muscles will begin to draw on fat and protein. The liver can convert these to sugar at a low level, but not fast enough to supply working muscles, so the muscles must burn them more or less directly. Burning fat and protein produces more metabolic byproducts than burning sugar or glycogen, and, in particular, burning protein (and to a lesser degree fat) produces a lot of ketones. Oddly, the heart burns ketones -- it's the only thing the heart can metabolize -- but exercising at a high rate with low sugar/glycogen produces a lot more ketones than the heart can burn, and more than the liver and kidneys can eliminate. The result is a state of ketosis, where the ketones become toxic and upset the body's entire balance, resulting in a major "bonk". (The feeling of this resembles dehydration or low salt, but, unlike with those, you don't "bounce back" when hydration and salt balance are restored -- it takes hours or days for the body to detox itself.)
So basically you want to keep the body supplied with sugar (which can be ingested as sugar or starch that is converted to sugar by enzymes in the gut) and also maintain the body's electrolyte balance and overall hydration. Any way you do these is good, and probably the most critical issue is what works for you in terms of palatability and digestive comfort/function, while achieving these basic goals. You want stuff that will be pleasant to ingest while achieving roughly the correct balance of the basic nutrients (including water). Often your tastes will change over the hours, and, in particular, strongly flavored foods, which may taste good initially, will tend to be less palatable as the day wears on. Also, it's necessary to be wary of ingesting too much salt/electrolyte or even simple sugar at one time, as these draw water into the gut rather rapidly, and can really upset digestion when you're somewhat dehydrated.
Note that you basically don't need protein or fat, at least not in any large quantities. A modest amount (eg, such as may be ingested in a snack containing peanuts) is fine, but there's no point in making an effort to include these, so long as you're getting some solid foods that contain modest amounts of them.
Added: I should mention that I have experimented with eating things like sausage sticks and jerky sticks on long rides, for the variety, and I don't recommend it. What I found is that this sort of thing is too "heavy", and the combo of salt and fat doesn't sit well on your stomach when you're mildly dehydrated and don't have time to stop and digest. Potato chips are a better choice, if you want something with "mouth feel", and they provide needed potassium.