The boys, aged between 11 and 15, went missing on December 8 from the Las Malvinas neighbourhood in the coastal city of Guayaquil.
Their families have said they went out to play soccer.
The case has sparked outrage throughout Ecuador, with protesters in the capital Quito and elsewhere demanding answers about what happened to the children.
President Daniel Noboa's government has deployed members of the military to patrol streets and assist law enforcement efforts amid a crackdown on crime, which has battered the country over the last several years.
Commanders of Ecuador's armed forces said last week the children were detained while allegedly committing a robbery and subsequently taken to a military base before being released.
Genetic testing confirmed the identity of the four bodies, found on December 24 in the town of Taura, the attorney general's office said on social media.
The confirmation came just after a judge in Guayaquil ordered 16 members of the air force be detained while prosecutors investigate their alleged participation. The lawyer for the military personnel said he will appeal the ruling.
"Let them go directly to jail where they belong. We want them to be detained (in jail), not in a military base," said Antonio Arroyo, an uncle of two of the missing boys, after the hearing.
Relatives of the dead boys say they were "soccer players, not delinquents". (AP PHOTO)
Protesters gathered outside the court in support of the children's' families.
Neither the defence ministry nor Noboa's office have commented on the identifications or the judge's ruling.
Both have previously expressed support for the families and the investigation, with Noboa proposing the boys be declared national heroes.
The investigation will last 90 days, the attorney general's office said.
The personnel under investigation were placed in military custody last week and could face disciplinary action for the way they detained the minors.
The youths were apprehended in an "unforeseen" manner by a patrol that had carried out an operation to support customs officials nearby, air force commander general Celiano Cevallos said on Monday.
No official report of the arrests or the alleged robbery was made and the location where the boys were allegedly released is unknown, according to lawyers representing the children's families.Â