Your dog is doing that because her anus is probably itchy. In this case, she will need to have her anal glands excised because they are building pressure on the anus. You can have a veterinary doctor do it.
my dogs anal glands were full when he does that so i have to take him and get them emptied or the will burst not good take them to the vet to get checked if its doing it a lot. this happens a lot in small dogs