First, is does not work all of the time, and I am not sure why it does work, when it works. I myself am in an experimental phase. I only passed this on to see if others noticed this, to get other's input if they have noticed something similar, and to possibly help others.
I learned about it accidentally. When visiting out of town to visit my kids, I noticed that I might sleep better if I took advil and benadryl (amidst the commotion they might cause, and the unpredictable schedule). I began to notice I could not only sleep better, but discovered that I also had fewer "night accidents".
As Dogsbc postulates, I think the benadryl does cause urinary retention, especially in those who have an enlarged prostrate (like myself). This prevents me from having to make so many bathroom visits.
I know some things that help in the mix… I try to end eating by 5:30 every night, and avoid spicy food, alcohol, citrus fruit, and salads.
Thanks for the questions. Hope my responses offer some help in the case you wish to engage in the experiment as well.