My 3 year old is the exact same way!!!
You have to watch her and try and catch her pooping face and what she does right before, that way as soon as you notice it you get them to the toilet and sit them down. Once they do it in the toilet a few times it’ll click. But I know when my daughter is on the verge of pooping in her underwear.
Following! In same situation with my son 😅