In Mexico, children are given two last names at birth, and keep those two surnames throughout life. That's built into information systems and assumed on government forms. It's required by government regulation, the Código Civil Federal (pdf) artículo 58 (Federal Civil Code Article 58), which reads in part,
El acta de nacimiento se levantará con asistencia de dos testigos. Contendrá el día, la hora y el lugar del nacimiento, el sexo del presentado, el nombre y apellidos que le correspondan; asimismo, la razón de si se ha presentado vivo o muerto; la impresión digital del presentado. Si éste se presenta como hijo de padres desconocidos, el Juez del Registro Civil le pondrá el nombre y apellidos, haciéndose constar esta circunstancia en el acta.
translation: The birth certificate shall be set up with the assistance of two witnesses. It shall contain the date, time and place of birth, the gender of the presented [child], the name and surnames that belong to him/her; and his/her fingerprint. If (s)he is presented as a child of unknown parents, the Judge of the Civil Registry shall give him/her a name and surnames, recording this circumstance in the certificate.
It's generally known that "Spanish-speaking cultures" use "two last names", see for example this article from Salem State.
However, in civil birth records written out in longhand in the 19th century, and written or typed even up to about 1930, it was common for the scribe to record at most one surname for each parent, and for the scribe not to record an explicit surname for the child.
So when did the convention of exactly two last names, one paternal and one maternal, gain the force of law? Trying to find the answer, I find various news articles and official notices about a recent change to allow parents to put the maternal surname first; but where can I find the original law that first required recording two last names, in Mexico?