Cockroaches are avoiding light not because they are afraid of it. They just understand that exposing themselves to lights might harm them where predators like lizards and frogs hunt them down. And also cockroaches are nocturnal.