These are craftier meanings, at least in US English.
"in school" often means you're a student (primary, secondary, or post-secondary school) in general. "He's still in school" can mean either he hasn't finished learning for the day(and thus not home yet or such) or that his education isn't finished.(X more years of standard mandatory education or X more years of University to finish) But it can also mean you're actively engaged in the activity, which I think I've heard people even use for remote-learning, though I don't feel that good about using it for remote-learning.
But if you say you're "in the school" you deliberately mean the educational building.
"in prison" sort of does the same thing, but since someone is locked up in prison and unable to leave, the distinction is much more rare. Let's say you're on the chain gang on the side of the road, even though they're really rare now. You're still "in prison".
If you said you were "in the prison", now you're not currently working a chain gang on the side of the road, but actively in a prison building.