So that is working as intended.
Is it now? But the OP's situation directly contradicts the statement:
If the warded creature makes an attack or casts a spell that affects an enemy creature, this spell ends.
"If the warded creature makes an attack or casts a spell"
OP isn't casting a spell or making an attack. Merely an already cast spell is existing.
"This spell ends"
This spell. As in Sanctuary. OP is having their Spirit Guardians spell end not Sanctuary.