No they do not.
D&D 5e is a game where things only do what the rules covering them say they do. Magic items each have their own description and they only do what that description specifically says, nothing more, unless there is another general rule somewhere covering their use. Also, a rule is not repeated if there is already a general rule that covers it; at most, there will be a reference to the general rule to avoid the possibility of unintended contradictions.
The description for +1, +2, or +3 weapons says:
You have a bonus to attack and damage rolls made with this magic weapon. The bonus is determined by the weapon's rarity. (DMG p.213)
So a longsword +1 grants a +1 bonus to attack and damage rolls, that's all. There is no rule anywhere else in the game that says anything like "The attack and damage bonus for a magic item will also apply to spell attacks and spell damage if the item can be used as a casting focus".
If there is still any confusion as to whether "bonus to attack and damage" includes spell attack and spell damage rolls we can look at other items that specifically state that this is the case. For example the Staff of the Magi:
This staff can be wielded as a magic quarterstaff that grants a +2 bonus to attack and damage rolls made with it. While you hold it, you gain a +2 bonus to spell attack rolls. (DMG p.203)
As you can see it clearly differentiates between can be wielded as a magic quarterstaff that grants a +2 bonus to attack and damage rolls and you gain a +2 bonus to spell attack rolls in the description. If the +2 bonus to attack and damage rolls applied to spell attack rolls as a general rule the description would not have included the specific rule about spell attack rolls.
This is also the case for other magic items. For instance magic shields where the bonus only applies to AC, not to anything else:
While holding this shield, you have a bonus to AC determined by the shield's rarity. This bonus is in addition to the shield's normal bonus to AC. (DMG p.200)
Even if it has a cleric's holy symbol emblazoned on it and is used as a Holy Symbol to cast spells the bonus only applies to what it says it does, to AC.
In case it is thought that this is not a deliberate and thought out rule/description for the Staff of the Magi, other items follow the same pattern. The Staff of the Woodlands, for instance, also specifically states that it has a +2 bonus to spell attack rolls in addition to the +2 bonus to attack and damage when wielded as a magic quarterstaff:
This staff can be wielded as a magic quarterstaff that grants a +2 bonus to attack and damage rolls made with it. While holding it, you have a +2 bonus to spell attack rolls. (DMG p.204)
The Rod of the Pact Keeper goes the other way:
While holding this rod, you gain a bonus to spell attack roils and to the saving throw DCs of your warlock spells. (DMG p.197)
It does not add to attack or damage rolls when used as a club, as it does not say it does. In fact, RAW, it is not a magic weapon at all, e.g. for the case where it is used against creatures with resistance to non-magical weapon's damage.