P.M.
She could have a bladder irritation or infection, B., so please check with her pediatrician on this.
Another thought that may or may not apply: There could also be an emotional hook if you have pushed her to train faster than she was ready.
There are hundreds of ways that parents can put their expectations on children, and depending on the child, she may internalize those expectations in ways that leave her feeling insecure. For example, do you exhibit more affection when she successfully uses the potty? Disapproval when she doesn't? Emotional reactions, either verbal or visual, to wetting or pooping her pants?
Since we do this so automatically and unconsciously based on our own upbringing, it can be hard to notice what's happening. But if it turns out she has no physical problem, I'd want to pay attention to this possibility.
Finally, she may have learned (probably accidentally and unconsciously) that she can hook you into a delayed bedtime and more one-on-one attention when she does this.
I do NOT think such behaviors are deliberate, conscious manipulation at this age, just the natural consequence of everything she's learned so far. But you might be sure she's getting all the mommy-love she needs during the day, treat the distress in a calm, cheerful, matter-of-fact way, and try to divert her attention to happy thoughts. Singing or playing music in her room as she falls asleep might be one way to help break the pattern.