There is also something called "Encopresis" which is an involuntary leaking of poop. It is sometimes in conjunction with, or made worse by constipation.
I would make sure, she is fine internally, before punishing her for something that maybe she cannot control.
You said she pooped 3 times, yesterday, in her pants. Is pooping 3 times a day, her norm? Or is it more? Then you said s he went potty in her pants then 20 minutes later, she pooped. Was this in her pants, again? So in the span of 20 minutes, she pooped twice??? Does she usually poop that much/often??? Next, is the "poop" in her pants actual poop clumps or skid-marks???
Next, have you tried just talking with her about it? Maybe something is going on. Things like this are usually emotion based. Any intelligent child who really knows their body cues, can and does have accidents as well. She is only 3.5 years old. Maybe talk with her... but not in a lecturing way. Just open and empathetic.
So maybe, she is not able to control it.
all the best,