I've been through this exact same border crossing many times and the U.S. guards there *are* complete @$$holes. It doesn't matter where you are from or how polite and cooperative you are. They like their authority and they use everything as a pretext to exercise it for the sake of exercising it. A little "hello, and welcome to the United States? May I ask the purpose of your visit today?" would go a long way.
He brought it on himself and made it worse. He would not shut up.
Wonder how it ended?