This is called "bed blocking" and is a massive issue in the NHS.
The title here is right but it's phrased badly. It sounds like the Police are at fault. Often people are arrested for the safety of themselves aswell as others, and the Police are giving them somewhere to stay rather than throwing them out on the street when they need treatment.
There's about 500 different issues rolled into one with bed blocking but
@Bigga summed it up when he said that it's essentially a lack of money problem. There's just not enough housing and it doesn't help that the private sector are the people who have picked up the slack, often charging huge fees to the NHS to give a mental health or end of life patient a shitty room somewhere. They're buying up old properties at auction, carving them up into as many rooms as possible, then packing them full of people that the NHS doesn't want to stay on a ward but still aren't well enough to go home.
It's a total disgrace.