It actually depends on the spell. For instance Mage casts Fireball in the same room as her/him then yeah its gonna hurt the mage also.
Mage or Priest casts a Flame Blade spell, a blade of flame appears of which the handle of said sword is also magical fire that comes out of the mage's hand, then no caster is not harmed.
Its wise to read the description of a spell before you cast it as there have been, more then one time, where a party member has cast a spell not realizing it will hurt the party that has hurt it.