I've had this problem for many years, I've talked to a sports doctor, and a sports nutritionist about it. They too are somewhat at a loss. Their advice was to experiment with different foods, times when I eat, and eleminiate dairy the night before and day of. And then try other things while running instead of gels. After my third marathon I could no longer eat the gels etc...without losing it. It also seems to be worse with running in the heat. In the winter I don't have as many problems. And it is worse when I increase my pace. The doctor said that when my body gets used to the increase in pace it should work out but it will be a slow process. Here is what I've done.
I get up and eat AT LEAST an hour before I am going to run, sometimes this is very early in the morning but I do it anyway. I tried a lot of different things but find that oatmeal, a banana, or toast with a bit of peanut butter seem to be the best things. NOTHING with dairy. Although I have lots of friends that drink a cup of coffee to "stimulate" them so they can go to the bathroom, I can't do that. But maybe it will work for you. I usually have a BM before I go out, and sometimes more than one. But even then occassionally I find that I still have an issue. Someone else replied to you about watching what you eat and how late you eat at night and I agree with that as well. For me if I eat lite and early it's better when I run in the morning. I also have one friend who makes half a peanut butter sandwich at night, puts it by her bed, wakes up two or two and a half hours before she runs, eats, goes back to sleep and then gets up just in time to go to the bathroom and do her run. So I think if you experiement with different foods and times the night before and an hour or more before you run you will eventually find the best for you.
As far as what to eat while running, I switched from gels to things like fig newtons, boiled and salted potatoes, pretzels, sometimes sports beans work. I eat those and with water and a minimum amount of sports drink. Someone else mentioned trying different sports drinks, I know a lot of people who are intolerant to some so maybe that is part of it.
The nutritionist I saw also mentioned not enough fiber in the diet, that seemed a little backwards to me, but I've tried to east more vegatables, fruits, and whole grains and that also seems to have helped.
I hope I was able to offer something that will help you. It's a real pain and I know how you feel. I too, like someone else who replied, take routes where there are potties available, and I take TP with me when I go for a long run.
Good luck!