We often use "at" for the mentioning of a precise location like; He is present at school. But why not say he is imprisoned at a jail instead use he is in a jail.
When referring to something like jail or school, at tends to refer to being at the physical location, and (unless the listener is aware of additional information) generally is preceded or succeeded by some verb phrase stating what the subject is doing at that location. For example, you might say, Joe works at the jail or Joe is serving time at the county jail. In both cases, since at does not make it apparent what Joe is doing, additional information is required. Now, if the listener knows that Joe is a law enforcement officer or a habitual troublemaker, one could simply say Joe is at the county jail and the listener would be able to infer what Joe was doing there.
School is similar. Stating that Julie is at the school has different implications depending on what is already known about Julie. If the listener knows Julie as a school-aged child, then the listener would infer that Julie is at school attending classes. If the listener knows Julie as a teacher, then the listener would infer that Julie is at school teaching classes.
In on the other hand implies that, not only is the subject at a physical place, but is also engaged in the primary activity that occurs at that place. Stating that Joe is in jail implies that Joe is incarcerated at the jail (regardless of what the listener knows about Joe) since incarceration is the primary activity that occurs at a jail. Stating Julie is in school implies that Julie is attending classes at a school since attending class is the primary thing one does at a school.
Hospitals are a similar case as well. Stating that Gerald is at the hospital would imply different things depending on what the listener knows about Gerald (is Gerald a nurse, or an elderly man, or an ambulance driver?). Stating that Gerald is in the hospital immediately implies that Gerald is hospitalized for the purposes of receiving care for an injury on illness.
In summary, at is somewhat more ambiguous as it specifies where the subject is, but leaves what the subject is doing up to inference. In is less ambiguous as it implies that the subject as at a location and is engaged in the primary thing that occurs at the location. In is short for stating that Joe is incarcerated at the jail or Julie is in school taking classes.
(I would like to start with general differences between in and at because in some parts of my answer I'm going to bring them up.)
We use at when we're talking about an address, a public place or building (a bus stop, the Post Office, the library etc.) and cases in which the location is irrelevant but what we do there is what is important (school, the dentist, dance class etc).
My mother is staying at 66 Argyle Street.
We study different subjects at school.
Use in to describe the physical location of something as part of a larger thing or place.
Liam has a flat in Paris.
About jail, it can be a countable or uncountable noun. As an uncountable noun we use it idiomatically in such phrases:
He was arrested and sent/sentenced to jail.
He went to jail for his crimes.
He just got out of jail a few weeks ago.
He was kept in jail overnight (in jail idiomatically means locked up as prisoners)
As a countable noun we use it with an article like the as in
He was locked up in the county jail.
We say at the jail idiomatically when you want to refer to jail as a general location where something happens as in
I visit her at the jail every Saturday.
We use at a jail when we talk about one jail that we don't want to be specific about it as in
Nineteen prisoners have been killed in the second riot in less than a week at a jail in Nebraska.
In both cases though there is a relevance between the place and an event, then we use at.
In the jail can be used in this sense, too, although it's not really idiomatic. I think here it's mostly used when we want to emphasise on the physical location as in
Playing sports professionally in the jail is something I don't think would work!
In the jail is mostly used when you want to refer to being there as a prisoner as in
He was arrested for drunkenness and spent a night in the city jail.
To put it in a nutshell, in jail and in the (usually the name) jail is used when you're locked up there.
At a/the jail refers to the general location and usually there is the implication of something happening there.
But why not say he is imprisoned at a jail instead use he is in a jail.
Fundamentally, there is not a problem with saying "He is imprisoned at a jail." - it is perfectly understandable.
That said, there is a nuance to stating it this way - it is redundant. Except in a hyperbolic sense, one would not be imprisoned at a school, for example. The state of being imprisoned implies at a jail without it being necessary to state this explicitly.