When you ask How did god make the sun on the fourth day if you need the sun to have a day like what, all the Bible believers will do is to come up with a bunch of nonsense in their trying to make sense of it.
The Bible itself is quite clear on the matter if you understand that it was written by people who did not know anything about the cosmos that we know actually exists, and their interpretation of what they saw is consistently what is shown in the biblical account of creation.
First, in contradiction to what some responders said that the Hebrew word for "day" in the Bible can mean an indeterminate length of time, that is overridden by the CONTEXT in which the word occurs. The days in Genesis chapter one DO have a specific context, since each "day" in that chapter is delineated by the term "the evening and the morning."
A 24-hour day in Hebrew connotation begins at the arrival of evening darkness and the period of daylight following the dark of night until the beginning of the next evening darkness.
That makes it clear that the days of creation were normal 24-hour days, and not "allegorically" longer. Any attempt to make them longer has no basis in the Bible and is an attempt to make the Bible conform to modern knowledge.
Now, let's take a look at why the writers of the Bible believed light was created before the sun.
The ancient Hebrews did not consider the light of the daytime sky to be caused by the sun. After all, the sky gets light before the sun appears in the morning and stays light for a while after the sun sets. They, of course, did not know about the atmospheric refraction of the light from the sun when it is just below the horizon, so it would have natural for them to think that the light of the daytime sky is separate from the sun's light.
That observation would have resulted in their conclusion about the order of creation events. Since, just before the appearance of the sun at dawn, the sky becomes light, and then the sun appears. To the scientifically naive, this would mean that the light of the sky was created first and then the sun.
In other words, they considered that there were two separate sources of light. During the first three days, the light of the daytime sky was the only source of light, and then after the sun was created on the fourth day, it was an additional source of light.
The light of day (meaning that of the daytime sky) HAD to have been considered separate from the light of the sun since the sun was not created until the fourth day.
That understanding is supported by Eccl: 12:2,
"before the sun and the light and the moon and the stars are darkened and the clouds return after the rain,"
The Hebrew word for light there is 'owr, which is the same word used in Genesis for light. So that passage is indicating that there are two sources of light during the day: the sun and the light of the daytime sky. If the ancient Hebrews thought the light of the daytime sky was caused by the sun, they would not have needed to add that light to the passage, for the darkening of the sun would also cause the darkening of the light of the sky.
Ps 74:16 also indicates the same thing:
"The day is thine, the night also is thine: thou hast prepared the light and the sun."
Meaning he prepared the light of the daytime sky and the sun. There the Hebrew word for light is ma'owr, which is a variation of 'owr.
All of which goes to show that the Bible is based on ancient Hebrew ignorance, myth, and superstition, and is not worthy of being believed in as a supernatural revelation.
That is also confirmed with my more detailed look at the biblical cosmos in my answer to this question.
https://answersrip.com/question/index?qid=20160126064750AAyTwxr