There’s a lot of misinformation about this topic, to judge by other answers, so let me clear up what I can.
First, Spain did not require anyone to take Spanish (or any other) surnames when they acquired the Philippines in the 16th century. It was almost three centuries later when they first required surnames (see below), and even then most of the names on offer were Filipino, not Spanish.
So how did many Filipinos get their Spanish surnames? For centuries, the primary process would have been through baptism in the Roman Catholic Church, at which time those baptized (or their parents) would often choose (Spanish) Christian names: Cruz, Reyes, Santos, Santo Tomas, Santa Maria, etc. These might or might not be passed down from generation to generation; some families, or perhaps some parishes, were pretty consistent with “family” names, while others seem to have allowed each individual to have a “surname” of his or her own, which might or might not be the same as his/her parents or siblings. Some Filipinos held on to local (Filipino) names, especially if they reflected pre-Hispanic “nobility,” such as Lacandola, but again this was inconsistent.
My sense from much research in the archives is that at the local level most Filipinos didn’t even bother with surnames, because everyone knew who everyone was, and identified them by their given name or nickname. Only when it came to baptism, marriage, burial, or (rare) dealings with official bureaucracy would a surname even be asked for, and I suspect some people could barely remember theirs, in the same way that some of us can barely remember the ID or passwords we’re supposed to use on various computer applications. (I was able to identify one Filipina who was known by 14 different names in around twenty years!)
In the 19th century, the Spanish, trying to rationalize the administration of the Philippines (once the tail-end of their empire; now, with the loss of the Americas, the jewel in the Spanish crown), got tired of this chaos. In 1849, Governor General Narciso Claveria issued a decree that everyone should get a proper surname, selected from a Catalogo Alfabetico de Apellidos [Alphabetical Catalogue of Surnames] sent out to each province. These surnames were to be given to the entire family, so that fathers and children would all have the same names all the time, and proper records would be kept by churches, schools, and local officials, etc.
The ostensible purpose of this decree was to avoid “confusion,” including the hypothetical possibility of people marrying others to whom they were too closely related (because they lacked surnames to tell them this!). Clearly the main reason was to sort out and simplify tax collection and other administrative tasks.
Contrary to the belief of many Filipinos, the Catalogo was NOT a list of exclusively Spanish names. In 1973 the National Archives published a phostatic copy of the Catalogo, unfortunately with a poor quality of reproduction. I was the ghostwriter for the Introduction (by Domingo Abella) to this reprint and have a copy of it in my possession. Those who claim it was a directory of Spanish names have clearly not looked into it, e.g., on p33 we find, among many others, the names coppocopy, copcop, copang, copit, copcopin, copag, copari, copada, etc. (These are randomly selected from literally hundreds more on the same page; there are tens of thousands in the whole volume.) In fact the decree specifically says that Filipinos ought not to choose names like “de la Cruz, de los Santos, and some others which are so numerous that they would continue producing confusion.”
But although the decree itself is clear, and the background to it fairly evident, we know very little about its implementation. It clearly varied from province to province, presumably according to the (Spanish) governors’ choices. In Albay, for example, there is a remarkable clustering of surnames by first letter, so that in the coast from Tabaco to Tiwi most names begin with the letters B & C; in Sorsogon, from E to L; in the Iraya valley M to S, etc. The town of Oas, dominated by last names beginning with the letter “R,” was said later (jokingly) to have claimed everyone with such last names, including Rizal and Roosevelt! Yet in the neighboring province of Ambos Camarines, no such clustering occurs; the new surnames for each parish come from anywhere in the alphabet. One guess as to this discrepancy - and it is only a guess - is that in Camarines someone took the whole Catalogo around from parish to parish, whereas in Albay they tore out the pages and sent different pages to different towns.
What is obvious is that there was enormous inconsistency in the implementation of this decree. Some Filipinos managed to retain old “family” names, although they were only supposed to be able to do this if they could prove that they had used them for four generations (and even then, not “de la Cruz, de los Santos,” etc.) Some Filipinos clearly chose Hispanic names; others apparently chose from the Filipino terms included in the Catalogo. We have no idea how much the parish priests (whether Spanish or Filipino) or even parish clerks (Filipinos) influenced these choices; it is entirely possible that they, rather than the families themselves, assigned surnames to many people. It is likely that a substantial number of people just missed out on the decree entirely - colonial administration was extremely haphazard in those days - though over time, as the colonial state grew and expanded its reach, it would have become harder and harder not to have a “proper” surname.
In the end, it is likely that most Spanish surnames in the Philippines today proceed from this 1849 decree and its (imperfect) implementation. We might guess that most Filipinos (or whoever made the decisions on their behalf) thought Spanish names were better than the Filipino alternatives offered in the Catalogo, but that, again, is just a guess. But we also know that many of these surnames antedate the 1849 decree, and presumably arose from earlier baptismal choices.