Essentially, you discover at the end that the doll Brahms was never 'alive' to begin with  nothing supernatural was occurring. Instead, it turns out that a 30-year-old man has been living in the walls moving the doll around to make it seem like it's haunted. Pretty weird.
The sequel throws that twist away by claiming that the doll was supernatural and was inhabited by a demon. The demon made the real Brahms commit murder. Then the movie ended with my boy Jude putting on the mask, indicating that the spirit of Brahms is inside him.