The alternator belt may be loose, causing it to slip and squeal. Check the tension of the belt and adjust it if necessary.
Loose Battery Cables
Loose battery cables can cause the headlights to flicker and the alternator to work harder, which can also lead to a squealing noise. Make sure the battery cables are tight and secure.
Failing Alternator
A failing alternator can also cause a squealing noise when the headlights are on. If the alternator is not able to generate enough power, the voltage will drop and the headlights will dim. This can cause the alternator to work harder and make a squealing noise.
Check Engine Light
If you see the Check Engine Light come on, it could be a sign that the alternator is failing. Have your car diagnosed as soon as possible.