I had a religion, somewhat like taoism. A bunch of apostles came to my main city and converted more than half of my people. Afterwards, I went with an Inquisitor to repel them, but my Inquisitor only increased the foreign religion. Is this a bug or is meant to be like that?
Any religious units you make will follow the majority religion of that city. So if you purchased the Inquisitor after that city was converted, then the Inquisitor would be of the foreign religion and would remove your religion when used. So yes, it's meant to be like that.
As for regaining your religion, you could purchase an Inquisitor in another city that is still Taoist. If you do not have any Taoist cities left, I don't know of a way to regain your religion. Sounds like a good time to pivot to another victory type!