You are right. On the first day of creation, God said, "Let there be light: and there was light" (Genesis 1:3). And from that day on there was an evening and a morning for each day of creation (Genesis 1:5, 8, 13). However, it was not until the fourth day of creation that our normal means of having a morning and evening--the sun--was created.
Before we solve the problem, let's make it a bit more complicated. God is light (1John 1:5). Also, in Genesis 1:1, we read about the creation of heaven and earth. Though we are told that the earth and deep were covered with darkness (Genesis 1:2), no such thing is said of God's heaven. With God there, we can rest assured that His light was there. So, how do we explain all of this? Let me give you my best understanding:
- The fact that God is light is an eternal attribute. He was light in eternity past. His dwelling place has always been a place of light. Therefore, light already existed in His heaven.
- After God created the earth and the surrounding universe, it was dark (or became dark). Then, after the moving of the Spirit of God on the deep, God brought forth light into the universe by His word. This light was fully answerable to His command.
- In order the create the order of days and nights on the earth, God established a pattern of evening and morning for the days of creation. Initially, He did this directly by fiat or command. When it was time for the evening, He turned the light down. When it was time for morning, He turned the light up. This was not problem for Him since He was the direct source for the light.
- On the fourth day of creation, as the creation of man drew near, God created natural means (the sun, moon, and stars) by which man could distinguish the days from the nights. These are still in effect today.