I dont think spanking a child of 2years old for something they may not have any control over is good, it only creates an anxiety and makes the issue worse ,too much punishment wont work ..She was potty trained very early and often children regress later .Has there been any upsets lately in her life any new happenings?
I never thought punishment or reward was appropriate for potty training. By your taking strong measures you have exaggerated the problem and very possibly caused your child to defy you by doing exactly what you don't want her to do. And you will be making an even bigger fuss (punishment) if you take her to the doctor. It is time to back off.
I see that you potty trained your little girl when she was one year old. Did that have to do with your placing her on the potty, or her using it voluntarily? There is a big difference.
As mentioned by the above poster, kids potty trained that young often do regress. Part of it is that at such a young age, they are not really potty trained, but mom/dad sort of learn their schedule, so are able to put them on the potty at the right time. It's much more common for kids to potty train around 3 or even 3 1/2. I can tell you that my 2 year old is still in diapers and his Pediatrician tells me that it is very normal.
Punishing her will just make things worse. She's not doing this to misbehave. It's possible there is a medical reason for it as well. It's good your taking her to the Dr. If there is nothing wrong medically, I would just back up a bit. Let her wear pull ups again if need be and just do not make a fuss about it all. She will come around. But I agree with the others..the bigger a deal you make of it, the worse the situation will become.