Because there is a specific exemption for border officials in the 4th Amendment. Until he was allowed to proceed and enter the county, CBP had the full legal authority to search everything on his person and in his possession.
Edit: y'all some have to like it for it to be true.
https://www.law.cornell.edu/constitution-conan/amendment-4/border-searches
It's a well-known exemption.
https://www.brownulr.org/blogposts/the-border-search-exception-to-the-fourth-amendment
Well-studied
https://yalelawjournal.org/essay/customs-immigration-and-rights
Legal arguments against the exemption including phone data are tenuous at best.
https://harvardlawreview.org/print/vol-132/the-border-search-muddle/
Y'all her your heads outta your collective butts and let's change the shit law.