Oftentimes, using "the" in front of a noun denotes the speaker referring to a particular, non-replaceable instance of an object; for example, when you and I point to "the car" in front of us, we denote only the car in front of us, and not the one speeding along a highway 50 km away from us.
However, the phrase "to run for presidency" does not denote a particular term of presidency; to say somebody wanted to run for presidency could mean they wanted to run for the 2022 presidency, the 2024 presidency, the 2025 presidency... etc. Therefore, if the two phrases you provided were to be used standalone, then "to run for presidency" would be the grammatically correct version; despite that, the phrase "to run for the 2024 presidency" is completely correct, due to there only being one 2024 presidency attainable.
(Also assumed in this answer is that the scope of the presidency is limited to one country's presidency. Otherwise, "the 2024 presidency" could point to many presidencies spanning many countries all occurring in the same year - in this case, 2024.)