The other man was indigent and was supposed to be cremated by the county. But the coroner's office staff did not check the case number, and the body of the wrong man was cremated.
"It was an oversight caused by human error," coroner's office spokesman Armand Montiel said.
But for the young man's mother, it was as if her son "died twice," the family's lawyer told the Washington Post.
"It was agony all over again," lawyer Luis Carrillo said. "They never had a chance to say goodbye. There was no closure."
Hernandez was taken to a hospital on October 4 after he was found unconscious in his car, Carrillo said.
Doctors told his family the next day that he was brain dead. His organs were donated, and the following week, the coroner's office picked up his remains for an autopsy.
In the meantime, his family members began making funeral arrangements. Carrillo said they had planned to have Hernandez cremated after the funeral.
Hernandez's body was with the coroner's office for about a week before his family members were told that he had been cremated, Carrillo said.
Montiel said that the agency immediately contacted Hernandez's family after the mistake was discovered.
County officials met with and apologised to the family on October 22, three days after the cremation.
"The department is profoundly sorry for any additional discomfort that this has caused the loved ones of Mr Hernandez," Montiel said.
Hernandez died of a drug overdose, according to the coroner.
The mix-up occurred as the Los Angeles County coroner's office is struggling to reduce a backlog caused by prolonged staffing shortages.
The department handles more than 8500 cases a year, and the Los Angeles Times reported in March that about 180 bodies were at the county morgue because of delays in processing.
That same month, Mark Fajardo announced that he was resigning after two years as the county's chief medical examiner-coroner.
"Ultimately, I wasn't supplied the resources I need to perform my duties," Fajardo said, according to the Times. "Every year, we made requests for positions that needed to be filled. . . . Each year, we were not supplied the personnel we need."
Montiel, the coroner's office spokesman, said the county's policy is to check the case number associated with the remains - a practice that has worked for almost two decades.
Carrillo said someone should have been supervising the staff members who made the mistake. He added that a lawsuit is in the works.