How much food should I carry cycle touring and what factors affect this?
I fear that the only useful answer is also the trivial one: you need one days food for every day between food supplies. Eat whatever you can get, and as much of it as you need.

My practice on longer tours is to have a "standard days food" made up of long-lasting items. Usually rice with milk powder, sultanas and sugar for breakfast (it's compact and keeps well) and noodles, beans and dried veges for dinner, then some sort of cracker biscuit with spread for lunch. These are bought wherever I can, so vary depending on where I am. But that's my fallback stuff, and I often carry the same 3-4 days worth of those for weeks at a time. But it means that as long as I have or can find water, I can cook and eat. I'll increase the stock if I think I'm going somewhere that doesn't have supplies, aiming to always have 3-4 days spare. Remember that a days riding is 3-5 days walking if your bike fails and there's no-one around to give you a lift, so plan to be able to get yourself out on foot if you have to.

Wherever I can I buy a day or two worth of fresh food and live off that. I'll buy muesli, milk, bread, fresh fruit and veges and eat them in whatever combination works (usually the more fragile or fast to go off first, leading to "watermelon, lettuce and avocado salad" for breakfast). Expect to eat local food, and be ready to live off local staples if you can - that will make your trip more interesting as well as cheaper.

I also carry small, robust gift items that are relevant to my story to give to people who provide hospitality along the way. I find that especially where I'm unusual local people will often be happy to talk to me and invite me into their homes. I will often trade an evening of story-telling for a meal and bed, then leave a thank-you card (cards are a photo of me with my bike, in a scenic location, and have my contact details inside). In the first world that's generally all I'll leave, because that's more than most people expect. They stick it on the fridge and it works as a conversation starter for months :) I find personal business cards very helpful too for giving to random people who are interested in you. Get them plastic coated or whatever so they last a bit longer and can survive a bit of dampness.