This is completely normal! Each child is different when it comes to learning how to use the potty. It is part of the process for a child to potty in certain situations and not in others. If she has just started a new school, she may not feel comfortable going #2 while there. She may have felt very comfortable going with the sitter, so it wasn't a problem for her. Children who are going through new experiences may also have to re-learn certain aspects of potty training.
The most important thing is to not punish her or make her feel bad for having accidents. Some pre-schools and day care facilities have policies regarding potty usage, so that may be why the teacher mentioned it. However, if they don't, make sure the teacher doesn't single her out from the class, that may hinder her ability to go #2 at school. When she has an accident, let her know that it is OK, and talk to her in a helping way. You can even ask her to help you "clean up" her accidents.
I have three year old twins who were completely trained. We even went on vacation with no issues. They went potty on the plane, at the amusement parks, etc. However, they started a new school this fall and one of my girls has at least two accidents everyday. She is adjusting to the new classroom, so her focus isn't on this potty training skill that she was previously mastering. When she has an accident, we and the school very kindly let her know that it is ok and we clean it up together, and move on!
Another thing you can try is to figure out if she is having her #2 accidents around the same time of day. If so, then have a potty break, around that same time, or just have them throughout the day. We have these at home because our girls get so busy, they sometimes forget. We just say "ok, it's potty break time! This has worked well.
Also, sometimes toddlers have painful #2 and then are later afraid to go again.
A book I highly recommend is "Everyone poops." Our girls love it and it helps understanding the process.
Hope this helps!!