Yeah I know, but why did they not calculate days differently so we have 300 days in a year or something when they decided hours etc.
because of the trip around the sun... if denominated comes into 365 and one quarter night and days. 365 times the sun comes up... and then a quarter of a day... and if that isn't inserted in a 1/4 x 4 = one extra day every 4 years you have years with extra weeks ever several years... or other even less rational things... as it goes now, we have 365 times the sun rises in a trip of the planet around the sun... and that quarter day is then added as on whole day on day 366 of the 4th year and the drift is controlled before it exceeds a day and starts to cause drift of seasons.
if you had 300 day years, some days would have the sun rise twice and when the day began would become kind of arbitrary in terms of sunrise and sunset.
Someone smarter than me will have to tell you why 24 hours.
why midnight? I suspect the day begins at midnight precisely because 'everyone' is asleep. Whenever people wake up, on the whole, it will be a
new day... If they wake at 5 or 7 or 9. (Until modern life, most people didn't really do shift work or start and end at odd hours - even most shifts start before midnight or sometime after). A lot of shifts are 12 hours from 6am to 6 pm or 7-7 or 8 hours - 6-2, 2-10, 10-6 with that last being the overnight. In many fire departments, the shift is 24 hours on, with 48 hours off with shifts A, B & C.
In pre industry/pre electricity, most work was done by daylight, so people got up with the sun rise or some time after and stopped most work with the dark*. Calling midnight the end/start of day meant work days didn't get chopped into different days, which is simpler if you have to calculate how many work days you have to pay for or get paid for. It's simpler if everyone follows a convention... end of day is 'x' everywhere. so it rolls across the planet. Someone decided 24 slices made sense... I am sure there's a mathematical reason to divide the planet 'time pie' into 24 hour slices like a chocolate orange. I will leave that one to someone else.
*Exceptions for night watches.