You cannot be attacked while the shield is on. Most likely, you received a delayed notification of the attack after the shield had expired.
Note that the shield you get from the Bazaar works differently.
The Bazaar shield activates the Skilled Defender spell, which gives you a better chance of defending your gem, but doesn't guarantee 100% safety.