This is not known.
See the Related Link
Because they are attracted to the lights at your house. You can buy non-attracting light bulbs if you want.
light
A hypothesis is a prediction on what you think will happen. For experiments on insects being attracted to light or heat, a hypothesis could be that insects are attracted to light over heat.
Some Moths, Flies they come tords light not the heat
There are various experiments that you can do for why insects are attracted to light and heat. Experiments can be done at night with a light source and heat source in boxes to see which one attracts more insects.
You cannot prevent bugs from being attracted to light because it is their nature to be drawn to light. You can use yellow light bulbs that do not attract them as much as other forms of light. The attraction to light is called phototaxis.
June bugs are attracted to light because they use the moon and stars to navigate at night. When they see artificial lights, they become disoriented and confused, leading them to fly towards the light source.
hormones
Insects, especially winged insects, are attracted to the bright light emitted from a light bulb. Spiders prey on insects, so the more insects are attracted to a certain place, the more spiders will be present there to eat them.
Only to the lights of fireflies of the opposite sex.
Probably Gnats
Moths and flies, primarily.