Horror shows us that there are multiple reasons why someone might lose their mind. Isolation is a big contributor: films like The Shining and The Lighthouse demonstrate the terrifyingly real effects of cabin fever. Someone also might be driven to insanity through the actions of another person. They also might just be made to feel insane through manipulation and gaslighting.
Insanity can also be used as a compelling storytelling tool. If we are led to believe that the narrator or protagonist has lost their mind, it makes them unreliable. This creates narrative ambiguity, something that leads to a variety of interesting and experimental techniques.