You normally have to do the ATPL groundschool in the same country as which you wish to complete the flying training and Europe is not a country.
So if you wish to do your flying training in Spain, you should complete the ATPL exams in Spain.
You can do it in other countries but you need the permission of both countries' aviation authorities and it's not straightforward.
Cheers
Whirls