M.C.
Wow, potty trained at 2?! Congrats on that! My son went through something similar. He was older and could talk but wouldn't say why he would hold the bm so long that it was painful.
Here are some things to try...
1. If she uses a potty seat, try changing to the regular potty with a step stool for her to rest her feet on. For my son, when he used the small potty, he was afraid that the bm would touch him and get his clothes dirty, when he was propped on the big potty he was afraid he was going to fall while he was using one hand to hold his shirt up... (an endless cycle!)
2. If she doesn't eat a lot of veggies or fiber it may be painful for her to pass the bm so she holds it as long as possible. Try increasing the fiber. Maybe one of those supplements like benefiber that's tasteless...
3. Remove any decorations from around the toilet. My son felt scared of one of the fake plant decoration on the back of the toilet because when he sat on the toilet for a bm it would touch his back. I removed the plant.
Good luck.
M.