'In the hospital' just means that you are inside the hospital building. Perhaps you've gone there for a check-up, or to visit a sick friend. We don't know why you are there - all we know is that you are inside this building.
'In hospital' has a much more precise meaning. It means that you're a patient. You have been admitted by the medical staff for treatment. You've probably been assigned a bed and will have to stay overnight, and you probably can't leave until a doctor has signed the documents to say you've been discharged.
The same distinction applies to prisons. A person who is 'in prison' is an inmate ( in other words, a prisoner), while a person who is just 'in the prison' could be in the building for any reason.
NB. A regional footnote : Speakers of American English don't seem to observe this distinction.