Here in Genesis 1:3 we have light, but the sun and moon were created in Gen 1:16
Gen 1:3 And God said, Let there be light: and there was light.
Gen 1:4 And God saw the light, that [it was] good: and God divided the light from the darkness.
Gen 1:16 And God made two great lights; the greater light to rule the day, and the lesser light to rule the night: [he made] the stars also.
I believe the reason for this is because light and darkness had different meanings during ancient times. Later these words transformed into the definitions we came to know.