This is extremely disturbing, and further evidence that the U.S. is a police state. I've never felt more ashamed of my country.
This doesn't happen all the time, but when police do break the law, or don't follow it correctly their actions come under scrutiny, data collected can be discarded from court, and even suffer personal blowback.
What you're asking is how did it happen? That's because it's illegal for a citizen to resist arrest (even unlawful arrest), so in the USA if you are being arrested, SAY you do not willingly submit, but DO whatever the officer tells you.
The thing many people forget is that the law doesn't happen just on the street in the US. It is a slow and flawed process, but police are just the front line of it, not the whole thing.
As someone else said, this will probably cost the police and city in a settlement.
Edit: Cops CANNOT just hold you for 24 hours. They have to have something to charge you with even if it's disorderly conduct. And you can then sue the local police if you have evidence that you were wrongly imprisoned. It is easy for cops to get cause so your chances of this are low, but it does happen. Once detained (with cause) I believe the 24 hour bit is true.
IANAL, this is based on my unprofessional research. I'd suggest you (everyone) do the same.
This varies state-by-state, actually. Even in those where it is legal, it is very foolish, of course.