Why did my OCD just go away?

I had compulsions and intrusive thoughts in 2017, which was when it started. I was put on medication to ease the OCD in 2018. There was a period during 2018 and 2020 when the compulsions were less intense. Then it got really bad and started to run me down in 2021 and 2022. This was when I resigned from my job at the time, because the compulsions and thoughts were that intense. I was diagnosed with psychosis around the same time. I was hospitalised at the beginning of 2022, and this was when the compulsions and intrusive thoughts disappeared. I haven't had a significant episode since the admission. I was also put on different medication for psychosis during the admission. Was it the anti-psychotics? Why didn't the sertraline work? Why did it stop then?