When addressing this question, it is helpful to understand the context.
Considering the scientific evidence, billions of years probably passed between the statement "In the beginning, God created the heavens and earth" (Gen. 1:1) and the next sentence in Gen. 1:2. So “the heavens” that included the luminaries were created long before the “first day” even began. (Also see "What is the Big Bang Theory?")
Gen. 1:2 and on describes God's terraforming of the earth over a period of what the account calls as "days". However, these "days" were most likely NOT literal days, but rather figurative "days". (Also see "Is the Earth really only 10,000 years old?")
So, how could God produce light on the first day if the luminaries were not "made" until the fourth day?
The Hebrew word rendered “make” in verse 16 is not the same as the word for “create” used in Genesis chapter 1, verses 1, 21, and 27.
Also the events of the six creative “days,” or time periods of special creative works, are described as they would have appeared to a human observer had he been present on the earth. So even though “the heavens” that included the luminaries were created long before the “first day” even began, their light did not reach the surface of the earth. On the first day, “there came to be light” because diffused light penetrated the cloud layers and became visible on the earth. The rotating earth thus began to have alternating day and night. (Genesis 1:1-3, 5) The sources of that light still remained invisible from the earth. During the fourth creative period, however, a notable change took place. The sun, the moon, and the stars were now made “to shine upon the earth.” (Genesis 1:17) “God proceeded to make” them in that they could now be seen from the earth.
For more, see:
Does Science Contradict the Genesis Account?
Search For Bible Truths - ARCHIVE
Search For Bible Truths - Search Guide