Using the toilet is work. It is a skill. It is the first real skill little ones learn that is not driven so much my need or instinct. When the novelty wears off it is just work. Work to remember, work to get there in time, work to leave what you are doing and attend to that need, work to navigate the clothing and the toilet itself, work to clean themselves up, work to wrestle the clothing back on, work to wash up.
Before you child was potty trained that was a self maintenance job you took care of for them. Now it is squarely on their shoulders. Think of any new skill you have tried to acquire as an young person or and adult. There was the period of excitement and determination at the beginning towards the new skill or goal. Then the there was the reality of what it meant to really incorporate that into your life perhaps you experienced a period of backslide or slacking? Followed by rededication perhaps a couple of these cycles? Eventually you worked through it increased in skill and capacity and what was once difficult has now become routine.
I would guess that this is perhaps what your child is going through right now. Encouragement. Find out what the hard part of the problem for them is. Is it the leaving of something fun that they are doing. Is it remembering that they are not wearing a diaper or pull up. Is is work to get their belt or clothing unfastened.
I have a just barely six year old boy that really struggles with wiping effectively when he goes number two and so I still will help him with that if he needs me to. He can manage alright but sometimes it is still a disaster. So if he anticipates it might be messy he will call for me to come and help him. He tells me before he goes in my ear that he might need help so be listening. He never has an accident but he is very small for his age and trying to wipe while not falling in is tough because he is so little. In his mind is much too big for a potty seat but the balance required while wiping effectively can be more than he can handle.
Another little girl of mine was also very small for her age and was afraid of the dark. She could not reach the light switch in the windowless bathroom. She was also very prim and proper and modest she could not fathom the idea of leaving the bathroom door a crack so she could go. I was not always available to go and help her with the switch in time. This sometimes caused her to have an accident. I had my husband install a motion detector switch at the wall plate that when I was not immediately available would turn on when she walked in this helped her a lot.
My oldest would get too absorbed in what she would be doing. Sometimes she would come to me racing like a maniac to get to the restroom in time. She would pass me like a flash pausing for a mere second to say breathlessly in a panic "I can't get my belt undone can you help me" and then continue on barely making it. Sometimes not.
I would counsel against any negative or punitive tactic. I've tried some in the past and I always regretted it. This is just a little sweet person trying to figure out how to be the boss of this body of theirs. It can be tough. Try and figure out what the problem is if you can and work with your child to try and solve it.
I have a sister in law that made a little chart for her little boy who was four and still sucked his thumb. It was work for him to stop so she put it in terms him wanting to stop. If he filled up the chart, if he had thirty days without thumb sucking he got to get a new toy of his choosing. They bought the toy and put it on top of the fridge where he could see it. She asked him if he wanted her to remind him if she saw him start to suck is thumb. He said yes. So they had this little deal that if he didn't suck his thumb for thirty days he would get the prize. So is wasn't her scolding him to not do something that brought him comfort it was her reminding him that he was working towards the goal of not sucking his thumb for thirty days so he could earn the prize. It was his job to remember but she would try and help him to remember. I know that this is a different thing but maybe something similar would help you.
I can be tricky but the answer is out there. It make take a little intuition, inspiration and patience she and you will get it figured out. Good luck.