Since you’re already on your way out, there’s no use of wondering about the why of the situation. But there is something you can (and should) learn from this situation.
The HR in any organisation is not your friend. Even if they appear friendly. Even if you commute together to work every day. Even if you have lunch together every day, take smoke breaks with them, forward reels to them on Insta, etc.
Their sole purpose is to ensure that they source the best possible talent for the company at the cheapest possible cost. Nothing more, nothing less. The moment there is even a hint of the possibility that the company is not getting their money’s worth for even a day (according to the HR or as communicated by your manager to the HR), they will do everything in their power to screw you over and salvage their situation.
They have been very direct in communicating to you that they have no patience for your mental health. Because they don’t care about the long term benefits of a healthy and stable employee. They are myopic and cannot see beyond the next deadline. The concept of loyalty only comes up when you try to resign quickly because you got a better offer. Because it means they are the ones losing money. Loyalty ceases to exist in their multiverse when it’s time to save money by cutting costs, aka layoffs.
So, never ever share your personal problems at your workplace. Not even within your team. And definitely not the HR. You might think they’ll be sympathetic and understanding, but you are actually providing them ammunition.
Firstly, get help for your anxiety. Professional help, not just a hug or a pep talk from your family and friends. Try and prep for the attacks when you’re in a normal state because you may not be in the best state of mind to think straight when it actually happens. So preparing for it is the best you can do besides the stuff that a qualified professional advises.
This is so your body can work on autopilot when your brain stops functioning rationally. Such that at your next job, if you get a panic or anxiety attack, you just have a glass of water and go out for a short walk. If it’s really bad, just tell your boss you’re feeling quite sick and need to take the day off and go home. Nothing more. If they press for details, tell them you’ve been recovering from an illness and you’re feeling weak and have a headache. You felt okay in the morning and so came in to work but it’s gotten worse. So you just need some rest and you’ll be fine.
All the best and things will work out. Have faith.