There are not exactly 365 hours in a year. A year has slightly more hours because it takes the Earth more than 365 days to orbit the sun.

Solar year: The actual time it takes for Earth to orbit the sun is approximately 365.2422 days. This is called a solar year.

Accounting for the extra time: Because of that extra fraction of a day, we add a leap day most years (years divisible by 4, except for centuries not divisible by 400) which adds an extra day approximately every four years. This keeps our calendar year synchronized with the solar year.

Number of hours in a year: Taking the extra leap day into account, on average, a year has:

365 days * 24 hours/day = 8760 hours (for nonleap years)

(365 days + 1 leap day) * 24 hours/day = 8784 hours (for leap years)
However, the actual number of hours in a specific year can vary slightly due to variations in the Earth's orbit. We can use the average though for most everyday purposes.