Mary Warren is the Proctors' maid or servant. When she comes back from court in Act II scene 2, explaining where she was and why, John is extremely angry with her for leaving without his permission. He is violent towards her, and once she tells him that she must go again to court the next day, he whips her. She is treated very much like the servant she is, and because of her defiant behavior, she is treated like a little child who doesn't obey her strict parents and deserves a "spanking."
Once she is cornered in court at the end of that same scene, Mary turns the tables on Proctor. She makes him out to be a devil's follower and she unites with Abigail, knowing that she holds the power over the court and the people in it. Mary screams at Proctor, "No, I love God; I go your way no more!" And with that, she has gained a power she has not yet held. She is treated as an adult and they begin to believe all she says. She realized that her only way to make others listen to her was to join Abigail. So Mary was a dynamic character who went from a whimpering little girl to a powerful ally to Abigail, and was treated accordingly.
Mary Warren is the hinge-pin in the play. She knows all about the deceptions and intrigues that have been foisted upon the community of Salem by Abigail. She is a servant in the Proctor's home and is treated accordingly and punished for insubordination and refusal to obey instructions in ways that seem incomprehensible to us nowadays.
Mary turns on John Proctor when she realizes that she can have power over him if she accuses him of witchery. She teams up with Abigail and discovers a new-found power. She is believed, and she receives attention that she is not used to having.
Toward the end of the play, when it appears that John Proctor or Elizabeth Proctor will be accused of witchcraft, John implores Mary Warren to tell the truth about the entire incident. When Mary accuses Abigail of the lie, Abigail then accuses Mary of bewitching her. She ends up fearing for her life and joins with Abigail in accusing John Proctor of witchcraft.