Welcome to Yorkie Talk. Your poor girl and you! I would guess that anxiety about being in an unfamiliar place, and being separated from you, triggered this problem. First the poop got stuck, and then she probably panicked and ended up making the mess.
My second Yorkie, Teddy, was 8 months old when we brought him home from our breeder. He was very well trained and socialized. I think he loved his new home and family so much and feared losing both.
I believe your girl loves you so much and panicked that she was losing you and her new home. 4 months is a relatively short time and she is probably not convinced yet that she is staying with you forever.
Give her lots of loving and reassurance that everything is okay.