The Treaty of Guadalupe-Hidalgo (by which the US acquired the Southwest from Mexico in 1848) permits unfettered travel by citizens of both countries across the border for distance of a few score miles. So, “border” inspections may occur beyond that distance. (IIRC).
It made sense in the days of the Old West; now things are a little different. I don’t know if the treaty has since been amended (with Mexico’s permission?) or not.
Seems to me that the very use of the dog constitutes a search. If it IS, where was the probable cause ? I’d be inclined to try that argument.