They’re there pending a mental health evaluation. In this situation, the person is held until a mental health practitioner is able to meet with them to evaluate their eligibility for a treatment program, or to see if they are competent to stand trial for a crime they committed while of questionable mental stability. Importantly, in neither example has the person been charged with a crime.
The administrative reason they are in jail is that they have been ruled a danger to self, others or unknown risk factor. They have to be contained until evaluation, and we have literally no other choice but to use a jail for that. There are only around 400 beds total at the iirc 3 institutions in Mississippi that are certified to perform forensic mental health evaluations, and… well they’re full. It’s either put them in the jail, where at least they have a bed, or chain them to the gurney and leave them in a hallway at an overworked mental health institute (which is literally what happens. But trust me that somehow its much worse than you think.)