Dear Abby
I am sorry you are facing this difficult thing for a parent, the worry and not knowing what to do or what to think. I think you are taking the correct first steps, to ascertain if there is a medical cause, and booking a counseling appointment.
These are questions I would have: How is her school work? How has she been doing socially? Up until this point, how were her moods, behavior and relationships with family members? I recognize that with Coronavirus, (if you're here in the States) everything has been disrupted in all of our lives. How is she dealing with all of this? How does she respond to her peeing on the carpet? Does she try to hide it or show shame, or the reverse?
Other than this, has she experienced any recent trauma or stressful event, of which you are aware? I would be prepared to discuss all of this, or any of it, with the physician and counselor.
Besides a medical cause, I believe there are various factors that professionals might look to including dietary, ADHD, Aspergers, Trauma such as sexual abuse, oppositional behavior, conflict in the family such as arguing, divorce, etc., and stress. I believe that each of these factors might lead to a somewhat different intervention or treatment.
I have two ideas about more resources. A Regional Children's Hospital will have a Child Development Clinic. There your daughter can see a Child Neuropsychologist who will give her a battery of diagnostic tests and she will also be interviewed by a social worker and psychiatrist, and possibly a child neurologist. We did this for my son.
The other idea I have if it is available near you is some kind of experiential and expressive therapy. This could be art or drama therapy or music therapy, or equine therapy. If something like this is available, I would choose among them based upon my child's interests. There may be nearby a program that would be free or sliding scale. These types of therapies in my experience can be much easier for a child, than "talk therapy" because they can be fun, and don't rely so much on talking, but on expressing, and feeling and being and doing.
This may sound far-fetched but martial arts training for a child this age can be very positive, with the right teacher, but only after trauma as been ruled out. For example, Brazilian Jiu Jitsu is gentle and it involves a strong relationship with a teacher. This alone can be a great support. That's what my own son did. It was a tremendously positive experience for my son.
Welcome to you. Please keep us posted. And I hope you keep posting. It helps.