I interpret Mary's visions to be based on the combination of mass hysteria and pure fear of being accused of being a witch. Mary herself admits to the power of being in a hyper-emotional crowd that is freaking out. She states that "I heard the other girls screaming, and you, Your Honor, you seemed to believe them, and...I-I promise you...I only thought I saw them but I did not." Anyone who has been in a scary movie theater, and had one person scream, only to set off everyone else, can understand that effect. When in a crowd of people who are terrified, the fear is contagious, and the mind easily plays tricks on you.
Her motivation behind some of her visions were probably just the hysteria speaking, but we also know that Mary is terrified that if she doesn't go along with it, the girls will accuse her of being a witch. At the end of Act 2, she refuses to charge fraud on the girls, stating, "I cannot, they'll turn on me". Unfortunately, she is correct in that prediction, and when they do turn on her, accusing her of being a vicious yellow bird coming to attack, Mary caves and calls John "the Devil's man" and declares her vision of John coming to her and saying, "I'll murder you...if my wife hangs!" Her declaration here is prompted purely by fear and self-preservation. If seeing a "vision" of someone tormenting her is what it takes to live, she'll do it.