There are a couple of factors that motivated Abigail's behavior as portrayed in the play. First, she knew she might get into trouble for engaging in dancing and other activities in the woods (conjuring spirits, etc.), and that if she accused others of having bewitched her it would transfer the blame onto them. Secondly, she thinks that if she can somehow remove Elizabeth Proctor from the picture, John Proctor will fall in love with her and rekindle their affair, as she hopes to marry him. Her obsession with Proctor motivates her to accuse Elizabeth of witchcraft.
Abigail is emboldened by her position of power as an official of the court, and sees her self as a sort of martyr figure. In Act II, Scene 2, the longest courtroom scene, Justice Danforth suggests she might be deluded, and she answers:
"I have been hurt, Mister Danforth; I have seen my blood runnin‘ out! I have been near to murdered every day because I done my duty pointing out the Devil‘s people—and this is my reward? To be mistrusted, denied, questioned like a... "
When he tries to reassure her that he does not mistrust her, she speaks boldly, trying to impugn his authority:
"Let you beware, Mister Danforth—think you to be so mighty that the power of Hell may not turn your wits?!— beware of it!"
She then begins to act as if a cold wind has entered the courtroom, and then, as Reverend Hale begins to state that he doubts her honesty, she pretends she sees a yellow bird on the rafters, which she thinks is a familiar sent by Mary Warren to attack her (Mary had earlier decided, at the insistence of John Proctor, to tell the truth in court about how the girls were only play-acting). She tries to declare her duty to God in accusing others.
"Oh, Mary, this is a black art to change your shape. No, I cannot, I cannot stop my mouth; it‘s God‘s work I do...".
The other girls (Susannah and Mercy) join in on the game and the Justice is convinced that she is being bewitched. Finally Mary can't take it any more, and in order to be put back in Abigail's good graces, she turns on John Proctor, accusing him of being in league with the devil. Because Proctor has earlier confessed to committing adultery with Abigail, humiliating her, she allows Mary to condemn him. It becomes clear how selfish and mean-spirited her motivations are, because she ultimately only wants to protect herself, even if it costs others their lives.