How to keep attic pipes from freezing in winter with gable vents
Where the pipes are now need to be part of your living space, thermally speaking.
Make an enclosure over the pipes, and
remove the insulation under the pipes and this enclosure, and
put that removed insulation over the enclosure.
The principle is the same as when you open kitchen cabinet doors on cold winter nights to prevent the kitchen pipes [which are next to an outside wall] from freezing.
Doors open = cabinet insides now part of your heated living space.
If you don't like NEC-compliant electricity in your attic, use a heated tape [mentioned already] but powered by a low-voltage xformer, with the xformer being fused.
Additional safety can be had with thermal overtemperature sensors but they may already have this to get UL approval.
The likelihood of a fire caused by this type of properly installed low voltage setup = ~0.00.