You may have bombed the interview. But once they interviewed the other candidates, they decided you were better than what they saw afterward.
It happens. The last time I interviewed candidates, the one that looked the best on paper spent almost the entire interview telling us we needed to buy some software she used at her previous job. After 5 minutes, I was ready to walk out - but I put up with the remaining 10 min, until my boss got there for her turn. The candidate did the same thing to her.