I wasn’t interested in the internal affairs of the catholic denomination, I was doubting that the government of Spain requires infant baptism to enter school.
Years ago likely means before 1980, and probably before 1975. Unfortunately, Franco is still dead.
I'm no expert in Spanish law either, but since the death of Franco in 1975, the Spanish govt. has frequently been antagonistic to the Catholic Church and friendly toward the resurgence of parties of the Left, which promote severe secularism and even atheism.
However, going back 40 years or more, under Franco 1939-1975, it's a different story. He clearly used Catholicism to assert a conservative national identity. He rebuilt with public money the churches which had been dynamited by the Communist/Anarchist parties, and considered Catholicism a bulwark against the Left.
This still would not have been right under Canon Law; but Bishops (with saintly exceptions) are all too prone to conform to civil law and ignore canon law, when it suits them.