There is nothing like the fear of not getting to the bathroom on a plane so that the potential traveler stays at home. Calm down. The situation is controllable.
Before the flight:
Reserve a seat in the hallway as close as possible to the toilet. This is not rocket science, since you don't want to have to go through two people to escape your seat. The closer you are, the greater the chances of being on time.
Pre-order a vegetarian meal. Why vegetarian? Airplane food can sometimes be enough to cause a bowel movement. Other meals include vegan, Japanese and kocher. It also means that you will get your food before the other passengers. The moment means that you can go to the bathroom before the masses do it after their meals.
Pack additional "underpants" for adults, wet wipes and a change of underwear in your hand luggage. Apparently, "diapers" is no longer a politically correct term. These items are not good for you in your checked luggage, so keep them within reach.
Read the Mayo Clinic literature. These proactive measures can help you control your bowels. The advice includes monitoring your diet, exercises and documenting your food intake.
Decide if you want to take an anxiety pill. Popping a diazepam / Valium can provide you with "false" security, but if it helps you be less afraid of having an accident, it may be worth the risk. Discuss the problem with a doctor.
Select over-the-counter medications as an option just in case. Pepto-Bismol, loperamide or bismuth are included in this list. Those who want to be even more confident can opt for prescription medications.
On the plane:
Talk to the flight attendant. Don't be shy, just explain that you have a problem. Hey, do you think they haven't heard it before? That way, if all the toilets are in use and there is a line, they will accompany you to the premises in business or in the first class, even if you have an economical flight.
Keep hydrated. Drink enough water since airplanes are known for zero humidity and do not want to dehydrate. Avoid alcohol, soda, coffee and other irritating drinks. That said, you don't want to drink enough water to leave every 15 minutes.
Go to the bathroom even if you don't think you have to.. That may sound strange, but sometimes just being there is enough to cause a reaction.
Realize that an accident is not the end of the world. Yes, it is shameful, but it is not fatal. If people look, smile calmly. It is likely that there are more passengers who will sympathize than not. And remember that once customs has passed, you will probably never see them again.