They organisers knew the courts had instructed police to stop it.
If they wanted to protest then they should've organised protests and demonstrations, which are perfectly allowed in Spain. That would be the democratic way. Not to insist on breaking the law and disobeying court orders.