Agree that you should refer for therapy. When I had therapy for a phobia, it worked by listing the scenarios related to my phobia from least to most distressing - so, for you, it might be 'toilet at home with nobody in' as least distressing, to 'toilet in a public place without a working lock' for most.
Then you work your way through them, noting how you feel each time, and exploring what you think your thoughts are - I used an app called FearTools to help note down each scenario and the feelings I had.
For example, identifying that I was catastrophising what would happen if X occured, forcing myself - using prompts - to challenge that thought, such as 'but that might not happen' or if it does, what will it change?'
Then you try the next step - so maybe it's the toilet at home while DH is in, but asleep. Then you do the same again - how anxious were you before it happened? What thoughts did you have while you were there - did you think something bad would happen? What bad thing? Why would it be bad? Are you using black and white thinking instead of looking at the nuances of the situation? Are you assuming how someone else will respond when you don't actually know? Etc etc
It might sound daunting now, but in tiny tiny steps - and with the app to help me examine my thoughts - it became manageable. I went from being unable to do the thing I was phobic of at all, with full panic attacks and vomiting at the thought, to being almost entirely free of fear. I'm still working on it, but my life has changed.
Good luck 💛