Earth Attack definitively works on commanders sitting behind walls: in Entwined Destiny, Ulm used that spell a lot, taking down miscellaneous commanders (and a Pretender) that were hiding in a castle. Not sure about regular assassination attempts though.
You will not target yourself with such spells, so it's fine (the Earth Elemental belongs to your nation, unlike the Ghost Riders). If a third nation targets the besieged province, I believe they will hit the besiegers (yourself) however.