What were you thinking wearing an untucked shirt to an interview? So, you're asking the question which means you want to learn and are open to hearing the truth. Interviews tell the prospective employer many things about you and most of it happens before a word is spoken. The way you showed up to the interview, reflects your cavalier attitude on getting the job. You didn't even put in the effort to look sharp. To a prospective employer, this is a big red flag on how you would treat the job should you get it.
Wearing an untucked shirt with a tie might be ok if you're getting a job at the local mall but not a corporation. Next time, make sure the hair is cut and styled, tuck in the shirt, wear your tie straight and with the correct length (front length should land just above the belt) and no visible tattoos, gauges, etc.
And as for the tour, Interviews are routines that have a set pattern which may include question time and sometimes tour time. The interviewer was going through the routine but had likely made the decision as soon as you walked through the door, i'm afraid.
"What's wrong with them?" Nothing. In some jobs appearance is very important. Applicants are generally at their best during an interview and you appeared sloppy. This isn't just about appearance, this is about your judgement, maturity and attention to detail. You dress for the culture of the business and you always err on the side of caution.
"Why waste so much time showing you everything?" Perhaps they have a standard procedure for interviews - it helps prevent lawsuits. Or perhaps the person interviewing you was not the decision-maker. Or perhaps you were on the short-list and they would have overlooked your appearance if someone better hadn't turned up after you.
P.S. You don't know if your appearance was the only reason you weren't chosen - it's simply the reason they chose to disclose. Just from reading your question I see another potential reason depending upon the type of work you were applying for.
I think they were just trying to help you by stating this. Their company culture requires people to be dressed professionally. A lot of placed dont. I had to tell someone, dressed very professionally, that I couldn't hire them because they had a lip ring. She didn't want to take it out if she got the job, so I couldn't hire her.
Difrerent companies have different requirements, You may fit in better elsewhere, or you can learn to dress a little more "old fashioned" and get a job at a more conservative company. just take it as a learning experience.
My brother-in-law in Canada used to tell prospective workers that if they would care to go home and get dressed properly he would then interview them - it was a firm that delt face-to-face with middle-aged people who expected a certain standard of dress from the staff. "Smart casual" means smart, not sloppy - did you think they wouldn't notice ?