Spain have their reason to do so since many young people were engaged in gambling, however there will be some indistry that may leesen their income due to this banning, it will just be a matter of how they can still attract players with ads at night only. There are other platforms to do ads as well. It can work if they can team up with the government on their implementation like setting up that players should be on legal age and some agreement terms for them to still keep their business.
Sure, Spain Government have specific reasons to do such kind of bans and I think every country will sure going to do the same thing if the vulnerable on the said issue were the young ones. But somehow these kind of bans may result to a less market strategy effectiveness of any affected gambling sites but on the other hand thinking that the one who can saw the adds are those who in legal aged are somewhat acceptable why this kind of ban were implemented.