I'm not defending it morally or legally, but based purely on logic it makes sense. Say you have two applicants for a job, they are the same age, attended the same schools, got the same or similar grades, and have the same amount and quality of work experience. The only difference between the two is gender. Statistically, both might be starting families in the near future. Only one is going to take maternity leave and cost the company money if she leaves, though. Who would you choose as an executive? (I know it's illegal to discriminate, that's not the point)
Now assume the same situation, except both are men, the only difference is race, and you cannot conduct a background check for whatever reason. You don't want to hire a criminal. Statistically black men have a higher crime rate then white (34% to 4%, or something around those numbers, I can't recall the exact figures). While the black man has a 66% chance of not being a criminal, the white man has a 96% chance. That's not being racist, it's a statistic.
So if, statistically, people of a certain background have a higher tendency to be terrorists (based purely off numbers), it would only be logical to stop them more often.
Now, again, I'm not saying it's morally okay, or legally (it's not, except in arizona). But I can't really blame people for it either.