The problem is that things are never that simple, I understand your point, on the surface this may seem to be a good thing as they are trying to protect the vulnerable, but we must understand that by doing this they are affecting the gambling, sport and the media industry, many jobs will be lost while we are still in the middle of a pandemic and we know that getting another job can be difficult, so is it worth it? And when you take into account all the factors the answer to that question becomes way more difficult.
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.