'He was in the hospital' =he was a patient
'He was at the hospital' = he went to visit someone who was ill,a patient.
'He was in the hospital' = We know in which hospital, we mwntion it before
'He was in a hospital' = we don't know in which one, he coule be in any hospital
question 3 : I would say some rice.
question 4 : it has nothing to do with countable/uncountable nouns. It's an expression.
question 5: In prison it's a fixed phrase and we do say I was at the university.
hope I helped