The geocentric illusion
One astronomical year is the amount of time it takes the earth to complete an entire revolution around the sun. During that time, the earth spins on its axis (approximately) 366.2422 times, in a west-to-east direction.
This creates an illusion, as seen from the surface of the earth, of the distant stars revolving around the earth, in an east-to-west direction, 366.2422 times per astronomical year. The sun, of course, also appears to revolve around the earth, in an east-to-west direction, but not quite as quickly as the distant stars. Because of the revolution of the earth around the sun, the direction of the line joining the earth to the sun changes a little every day, which causes the apparent position of the sun relative to the distant stars to change a little every day. In an entire astronomical year, these small changes add up to one complete rotation - in other words, the distant stars appear to "lap" the sun in their progression around the earth, exactly once per astronomical year.
We conclude from that that the sun appears to revolve around the earth 365.2422 times per astronomical year - that is, exactly one less revolution than the distant stars complete in the same amount of time.
Sidereal and solar days
A sidereal day is the amount of time that it takes for the distant stars to appear to revolve once around the earth. That is clearly 1/366.2422 times an astronomical year, and that works out to (approximately) 23 hours, 56 minutes, 4.09 seconds.
A solar day is the amount of time that it takes for the sun to appear to revolve once around the earth. On average, this is 1/365.2422 times an astronomical year, which is (almost exactly) 24 hours. This is an average - solar days can actually be up to almost half a minute longer or shorter than 24 hours. But our time system is based on a "day" that's equal to the average solar day - obviously 24 hours - and therefore we can say that an astronomical year is (approximately) 365.2422 of our days.
Variations in solar day
In general, a solar day is either slightly more or slightly less than 24 hours, and it varies according to the time of year. There are two different causes for this variation, one with a period of a year, and one with a period of half a year. The two causes sometimes reinforce each other, and sometimes partly cancel each other out.
The first reason for a variation in the length of a solar day is the slight tilt between the equator and the earth's orbit. This causes the apparent direction of the sun's path across the backdrop of distant stars to vary slightly. At the solstices (June and December), its direction is west-to-east, relative to the distant stars, but at other times of the year, there is either a slight northward or slight southward component to the sun's apparent trajectory. What this means is that at the solstices, the apparent position of the sun is retreating directly from the apparent trajectories of the distant stars, which means they are "overtaking" the sun most quickly at that time; and less quickly at other times, when the apparent position of the sun is retreating at more of an angle towards the north or south. The effect of this is to lengthen the solar day slightly close to the solstices (particularly in June and December) and to shorten the solar day slightly close to the equinoxes (particularly in March and September).
The second reason for a variation in the length of a solar day is the ellipticity of the earth's orbit. The earth does not maintain a constant distance from the sun. It reaches its maximum distance in early July, after which the sun's gravity starts to pull it in. So for the second half of the calendar year, the earth is getting closer and closer to the sun, and also increasing in its speed around the sun. It reaches its closest approach to the sun in early January, then starts to move outwards again, with the sun pulling it back all the time, and slowing it down. Therefore, its closest approach is also the time when the earth is travelling fastest; and its furthest distance occurs at the time when it is travelling slowest. The variation in the speed of the earth around its orbit results in a variation of the speed of the sun's apparent path around the earth. In December and January, when the sun's apparent trajectory around the earth is fastest, relative to the distant stars, it's slowest in terms of its elevation above the horizon. In late June and early July, the opposite occurs, and the sun's apparent trajectory is fastest in terms of its elevation above the horizon. This means that the solar day lengthens in December and January, and shortens in the middle of the year.
These two causes work together in December to produce the longest solar days. The shortest solar days occur in August. At other times of the year, such as February and October, the two causes tend to work against each other, and give solar days that are close to 24 hours. The pattern of long and short solar days is a little complicated, but over the course of the year, the average of 24 hours is maintained.
Most of the world uses a calendar system called the Gregorian calendar, in which some calendar years have 365 days, and others have 366. The idea of this calendar is to make the average calendar year close in length to an astronomical year. It has a leap year every four years, except for three "exceptional" non-leap years every 400 years. A total of 97 leap years out of 400 gives us an average calendar year of 365.2425 days, which is close an astronomical year.
A much more accurate calendar is the Solar Hijra calendar, used in Iran and Afghanistan. It also has years of 365 days and years of 366 days, with a leap year occurring either every fourth or every fifth year, in a complicated pattern that spans 2820 years. The pattern gives us 683 leap years out of 2820, for an average calendar year of 365.2422 days - incredibly close to the length of an astronomical year.