A.M.
i agree with some of the other posters points.
first is she taking her pants off or is she just playing and having an accident? did she ever have accidents or did she have to be reminded about going? if she is just having accidents, i would think it may be a UTI or bladder infection, among other medical possibilities.
if she is taking her pants off and peeing, i would take it seriously. and look into when this started, were there any changes? any changes in her personality? it may be for attention, yes. but it also may be something more serious going on and she is trying to get you to help me. im not saying anything is going on, but you would never forgive yourself if she was reaching out and you werent there for her. i would not punish at all at this point. its not a normal thing for kids, esp girls to do, so i would look for a cause.
either way, i would def take her to a doctor asap.