Barcelona was part of Al Andalus for quite some time (i.e. Umayyad Caliphate). All of the Iberian Peninsula but the northwesternmost part was part of Al Andalus. So in their sicks minds that is the only reason they need.
From 711 to 801 afaik so not that long compared to most of the Iberian Peninsula.
And Barcelona, and Spain in fact, was in alert level 4 out of 5(high) before the terrorist attack happened. So it was not an "easy target" by any means.