Posse Comitatus does not apply to the military used for border enforcement. I do not know where that crazy idea got started the idea that the military cannot patrol borders?
“Posse Comitatus does not apply to the military used for border enforcement.”
It has been interpreted (and written into Army and Navy Regulations) to bar the Military from domestic law enforcement functions, including at the border.
So they have long been prohibited from arresting people for violating US or State Law (like drugs or immigration). They could engage an invading military force.
In recent years there has been some additional flexibility written into the specific instance of enforcing border security, but it has not yet been tested.
The National Guard however, is specifically allowed to be deputized by State Governors to perform Law Enforcement functions, including arrest and detention. There is a long history of their law enforcement use - mostly during natural disasters, but also during rioting.