CBP is a law enforcement agency. They have a real job to do. They frequently don't do it well, in their defense of Fortress America, but they have the authority of cause you serious problems if you don't comply. Worse case is most likely a wait in secondary if you don't answer questions to their satisfaction, but you'll eventually get in. Welcome to Fortress America.
TSA is a joke and the clerks need to be reminded of that frequently. They don't have much of a real job to do, so they invent things to do. They usually don't do it well, but they don't have much authority to cause a serious problem beyond a confused delay at screening and a retaliatory grope. Stupid is as stupid does.