Attacks are attacks and spells are spells.
Attacks work like this.
Strength = Attack or
Dexterity = Attack if finesse and Dexterity is higher than Strength or
Dexterity = Ranged attack or
Strength = Ranged attack if considered a throwing weapon or
Dexterity = Ranged attack if considered a throwing weapon that also has finesse
It isn't as complicated as I probably just made it sound.
Spells work like this.
Primary Spellcasting Statistic = Attack modifier or spell DC.
That's it.
So what this means is that spells are spells no matter what. Unless the spell's description says it uses a regular melee attack, or something to that effect, it will always use your primary spellcasting statistic. Wizards will use Intelligence for Firebolt or Shocking Grasp. Sorcerers, Warlocks and Bards will use Charisma. Druids and Clerics will use Wisdom.