The spirit of Bethsheeba had latched on to the necklace which Lorraine had dropped in the basement of the Perron's house. My guess is that, it created a connection with the necklace's pair that was at the Warren's house (remember the violently shaking necklace in Judy's room?!). This explains the presence of Bethsheeba's spirit at the Warren's.
Now to explain, what was she doing with the Annabelle doll, you'll have to go back a little to the scene where Lorraine was combing Judy's hair sitting at the very same spot, in the very same chair! This is what Bethsheeba is imitating.
Why is she doing that?!
I have no clue! After all, the activities of evil spirits aren't really logical. They do whatever they do to spook and scare the crap out of you. And I'd say she was pretty successful at that. However, she was a twisted soul which had tried to kill its own offspring and that of others. The mother-child relation wasn't sacred to her, and I guess she derived some kind of pleasure mocking it.