Why doesn’t Shield Guard allow you to guard against an offensive spell? Ranged attack just means shooting basically correct?
Ranged Attack is specifically an attack made with a Ranged Weapon. Attacks with spells are Arcane Attacks, which share a lot of similarities with Ranged Attacks but are not Ranged Attacks.
Since Shield Guard specifically says “Ranged Attacks” it doesn’t apply to Arcane Attacks.
I added the rules tag to the topic to make sure it’s identified as a rules question
Note that other than the “target in melee” penalty, the similarities shared by ranged and magic attacks are also shared by melee attacks (including having a maximum range).
Shield Guard is likewise ineffective against melee attacks.
Aside from the aforementioned rules, from a fluffy perspective, it’s just very difficult to block a spell with your shield or body, as a model with shield guard would want to do. Taking a bullet is one thing, but how would one block something arcane that isn’t a projectile? Even something seemingly plain, like a lightning bolt, can spark and arc around a shield guard to its intended target.