“It’s a chronic problem,” said Scott Shuchart, who worked in the Department of Homeland Security’s civil rights office from 2010 to 2018. “The number of cases that fall through the cracks of that system, it may be very low as a percentage, but it’s certainly nontrivial as a raw count of cases.”

Mr. Gonzalez Carranza was lucky, according to his lawyer.

The problems began last January when Mr. Gonzalez Carranza, who had entered the country illegally, went to his lawyer to renew a temporary permit to live in the United States that he had been granted based on his deceased wife’s military service. They learned that a removal case against him had been opened even though the permit was still valid, but he hadn’t heard about it because the notices had been sent to an old address. Months earlier, it turned out, he had been ordered deported.

Knowing that he could be arrested at any time, Mr. Gonzalez Carranza and his lawyer moved quickly to prepare documents to halt the deportation. But before the papers were filed, immigration agents arrested Mr. Gonzalez Carranza on April 8, pulling him over as he was driving to work. He said he remembered flashing lights and then “a lot of cops around me pointing guns, screaming, saying ‘Open the door!’”

Mr. Gonzalez Carranza had first entered the United States on his own at the age of 14 and moved in with an uncle in Phoenix. Rather than going to school, he started working for a carpeting company and met the woman who became his wife, Barbara Vieyra, at a nightclub for teenagers.

The couple moved in together, had their daughter, Evelyn, and they married. Soon after, Ms. Vieyra joined the Army to help support her family. She served in a military police unit in Korea and was 22 when she was killed in Kunar Province, Afghanistan, according to news reports.

Mr. Gonzalez Carranza remained in the United States without permanent legal status, sharing custody of his daughter with his wife’s parents. His wife’s military service should have allowed him to remain in the country legally until April 20, 2019.

He could make none of that clear to the officers who came to arrest and deport him. During the days he spent in Mexico, Mr. Gonzalez Carranza said, he passed the time inside a Mexican government office because it was close enough to the border that his American cellphone still worked and he was able to talk with his lawyer. He slept at a migrant shelter, mostly filled with people waiting to seek asylum in the United States.