After he left Arcadia, Mr. DiNardo worked for his father’s concrete company, but he wrote on Facebook in November that he had moved on to sell “firewood,” which some friends said was a code for drugs. Friends said he sold guns and marijuana, and one friend said he wanted to move up to selling harder drugs and larger quantities.

Friends and acquaintances said Mr. DiNardo changed last year after he crashed a four-wheeler while alone in the woods on the family farm in Solebury Township, about 45 miles north of Philadelphia. According to some accounts, he was stranded for hours, suffering from broken bones, until his father and younger brother found him. Some friends said he suffered a serious head injury.

A longtime friend said: “That incident drove him over the edge. He was a more violent individual.” The friend asked not to be named because of a desire to not offend Mr. DiNardo’s family and an agreement among his friends to stay silent.

At an arraignment hearing last week, a Bucks County prosecutor said Mr. DiNardo was once diagnosed with schizophrenia. Members of his family and a lawyer representing Mr. DiNardo declined requests for more information about his mental health. One longtime friend said Mr. DiNardo twice spent time in a mental institution.

Mr. DiNardo, according to the authorities, instigated the killings of four men — Jimi Taro Patrick, 19; Dean Finocchiaro, 19; Thomas Meo, 21; and Mark Sturgis, 22 — with Mr. Kratz as an accomplice to three of them. They were each charged with multiple counts of homicide.

Mr. Kratz, who has a history of burglary, theft and other arrests, grew up moving around different Philadelphia neighborhoods and suburbs. He worked from 2014 to 2016 as a dishwasher at a retirement community, The Philadelphia Inquirer reported, but was better known by some people for terrorizing his former girlfriend’s neighborhood.

Residents recalled him as the skinny teenager in a black hoodie accused of breaking into homes and stealing jewelry and landscaping tools, the newspaper reported. His former girlfriend’s mother said she had long suspected he stole her Yorkie.