WOW -- THIS IS SERIOUS.
Let's be practical....She's fine at home and continues to drink and use the potty #1 and #2 at home? The behavior began at daycare and spread to other public, less controlled/safe places? What would I do?????
LEAVE THE DAYCARE, if that's where the behavior began -- "what happened" is secondary to her comfort level and behavior. It really sounds like an action triggered this, and the fear spread. She's 4 for pete's sake.
LEAVE THE DAYCARE for your daughter's wellbeing because she has been avoiding using the restroom and hurting herself at her own expense. Something or someone hurt her.
and, LEAVE THE DAYCARE for your daughter's sanity because until you know FOR SURE that nothing happened there, your child is not safe and is fearful daily.
You can easily find another similarly priced and convenient daycare at qualitychildcareforchildren.org -- you cannot easily make this better for your daughter in the current situation.
Once she's in a new daycare a week or so, if the behavior reverses, try to talk to her about what happened -- now she will not fear being "found out" by someone for talking to you. Was it a child bullying or locking her in or constantly accompanying her without leaving her alone? Was it a substitute or new teacher she was fearful of for some reason? Did they use a "seclusion/time-out room" and lock her in? Did something happen "in public" or while they were on a fieldtrip or with a stranger in that "setting"? Teachers are great but cannot be there all the time to see what happens.
If she continues the behavior a month after leaving the daycare, perhaps see a child psychologist, or see if there are other "triggers." This really hits a personal note, as I was abused by a care provider when I was 5 -- I was so scared of being punished for not keeping "our little secret" I still remember that talk with my mother today.
I'm so sorry to hear of your daughter's fear -- it makes you feel so terribly alone and uncomfortable, and then to have developed such great fear over a necessary, unstoppable body function... I'm sure you can help her!