But I think some of them are just buffoons who like to bully naturalized citizens, as they feel most naturalized citizens (especially recently naturalized) are less secure in their citizenship than born citizens, and are more likely to accept the abuse because of already tolerating such abuse for years as visa holders and permanent residents. So they may ask questions which are unnecessary or even illegal, but they get away with it because the individuals they harass are not willing to take a stand against them.
Interesting perspective, but in my 22 years as a non-immigrant visa and GC holder, I have never been treated badly or even like an outsider. Most officers welcome me "back home" when I come back, and customs barely gives me another thought. It will be interesting to see if this changes because I am a newly naturalized citizen. My guess is no, because it all comes down to the individual's attitude and demeanor when they address the officers at the airport. Human nature and instinct will always play a role regardless of non-immigrant or citizen.