I am so very glad you wrote. You are correct to be concerned. I am, too. I suspect the religious crisis and your self-punishing behavior are related. In most religions, moral judgment is balanced by forgiveness and compassion for yourself. Somehow those two important concepts have gotten out of balance for you. I hope you are talking seriously with a religious advisor to help you as you struggle with these issues.
Your stomach aches might be caused by the tension you are feeling. On the other hand, it’s always a good idea to have your doctor check it out if you are feeling ill much of the time.
It might also be helpful to talk to a mental health counselor to sort out what’s going on with the people in your brain. It could be simply a way you have developed to try to figure out a problem or it might be caused by something more serious. I can’t know on the basis of a letter. At the vey least, it would give you some peace of mind to sort it out with a professional who can hear your whole story.
You are asking big and important philosophical questions that have no easy answers. It’s important to turn to people who can give you support and guidance along the way.
I wish you well.