The 24 hours (exactly) definition of the mean solar day only applies if you use the UT1 time scale. As others have mentioned, the mean solar day is not the average of the shortest and longest apparent solar day, and you have to consider the Equation of Time to calculate the mean solar day by averaging all apparent solar days in one year.
If you use the definition of a second based on the metric system, which is used by the atomic time (TAI), UTC and the terrestrial time (TT) time scales, the length of the mean solar day is not exactly 24 hours. The definition of the SI second, apart from being an atomic scale, is based on the mean solar day in 1900 as determined by Newcomb (in reality it corresponds to the mean solar day in about mid 19th century), when the Earth's rotation was faster than today. Today the mean solar day is slightly longer than in the past (when measured by an atomic clock), and the length of the mean solar day in TAI seconds is greater than in UT1. To correct for the difference, leap seconds are introduced 0-2 times per year in the UTC time scale based on observations of Earth's rotation, to keep UTC in sync with UT1 to less than 0.9 s. These corrections are publised in advance by IERS in Bulletin C. There have been 27 leap seconds inserted in the last 46 years, which equals to about 0.6 s per year difference between the length of the mean solar day between TAI and UT1, or about 1.6 ms per day (see Figure 1 and 2).
The length of the SI second depends on the location, and TAI is based on observations done by atomic clocks in various laboratories around the world ("UTC(k)") and corrected for the geopotential on the sea level. TT is a theoretical length of the SI second on the geoid, and as such is never known perfectly. Approximation of past TT is revised annualy by BIPM. In contrast, TAI and UTC are determined and kept fixed after about 1 month past the fact (published regularly in Circular-T by BIPM). Laboratory-specific UTC(k) time scales and the GPS time (based on the US Naval Observatory Master Clock) are known in real time. Other time scales include the geocentric time, barycentric time and the ephemeris time. The length of 1 s is slightly different between all of them, some of the differece is due to time passing differently based on location in the gravitation potential. For example, time passes faster in the solar system than on the Earth's surface by about 0.5 second a year.
Historically, time measured by the rotation of the Earth was the most accurate, and the mean solar day was assumed to be constant equal to 86400 s. This changed with the introduction of the ephemeris time, later superseded by the quartz clock and the atomic clock, which lead to re-definition of the second. They will deviate further as the rotation of the Earth slows down.
References:
Figure 1. Excess to 86400s of the duration of the days, combined GPS solution, 1995-1997. From https://www.iers.org/IERS/EN/Science/EarthRotation/LODgps.html
Figure 2. TAI-UT1 and TAI-UTC. From McCarthy and Seidelmann (2018).