Maggie Luna, a single parent whose first prison term began in 2011 after she was convicted of writing bad checks, has lost custody of her three children. A Texas judge terminated her parental rights in 2014 after she failed a drug test, she said. Unable to afford a lawyer to file an appeal, she said, the ruling sent her into a downward spiral of drug addiction that led to another prison sentence.

Her youngest daughter was adopted, her 9-year-old son is in a psychiatric hospital, and her oldest, 13-year-old Delilah, is living with Ms. Luna’s mother.

Delilah was in kindergarten when her mother was first sentenced. For a while, she and her siblings lived with Delilah’s father, who occasionally took them to visit their mother.

Both mother and daughter can still recall the pain of those visits.

“The guards would say no touching,” said Delilah, who at the time was 5 and too old to sit on her mother’s lap. “We’d have to sit on opposite sides. It was really hard for me to understand.”

The most searing moments came at the end of each visit, when guards escorted Ms. Luna out of the room as her distraught children looked on.

“My son’s screaming and there’s nothing I can do,” recalled Ms. Luna, 39, who has been out of prison for two years.

Since 2016, parental incarceration has played a role in nearly 20,000 children entering the state’s foster care system every year, according to the Texas Department of Family and Protective Services.