Funnily enough I do have a very similar story to yours...
Friend of known for many years. We've had this pattern of a 'close' friendship for a few months. Then she goes silent (could be for over a year+) then it reignites , and so the pattern continues.
She suffers with her mental health (as have I in the past) and I've always been there for her because I understand. I don't know how to put this without sounding arrogant: but I have always been quite independent with my MH struggles and the only support I've ever really wanted or sought out is medication and some solidarity from a trusted friend (her in some instances) she's more of an external crutch seeker and 'lapses' into believing outsider's can fix her or be in some way to blame for her struggles. But I've always stood by her even when it's frustrating to watch her not help herself.
Anyway: the last time she was in a bad period with her DH and considering divorce. I dropped plans to meet her at late hours just to listen to her. Took her to solicitors appointments. Sent her so many messages and listened at all hours to hers. I invested a lot of time and energy into her.
Then she stopped replying. So I read about it and the right thing to do and decided to keep on sending the odd message to show her I was still there. Then I changed tack and just sent her light hearted memes or chit chat about my day in case she wanted light relief. I kept reiterating i was always happy to pick up where we left off anytime. Then I stopped messaging and thought I'll give her a little break.
I assumed her MH must have been bad.
I then saw pictures of her partying with friends on social media and lots of back and forth messages to these friends about meet ups they were having or planning. It kicked me in the teeth and I felt really hurt. I decided to stop wasting my time after that. I felt it was really disrespectful and showed she took my support as and when she needed and discarded me when my job was done. I also had periods in that time when I could have really used a friend. I came to the conclusion it had become very one way.
She'd told me in the past about how friends had just 'had enough and dropped me because of my MH " - now I realise they probably had the same done to them as me. Sadly I think she will always be a 'victim'.
One conclusion I did come to was this (and I'm pretty sure it's accurate): she associated me with bad times in her life mental health wise because it was often when she contacted me, when she needed help. So when she was feeling better she latched on to other friends who didn't know those struggles as she wanted to escape it.
But that's no good for me. I'd end up used. So best the friendship finished.
I wonder if it was the same for your friend perhaps?