The reason for Mercury not being the hottest planet despite its proximity to the Sun is due to its low mass and lack of atmosphere. This prevents the planet from retaining heat effectively.
Mercury's inability to retain an atmosphere results in the planet releasing most of its heat into space, rather than distributing it across its surface. This distinction makes Venus, the second planet from the Sun, the hottest planet due to its dense atmosphere that traps and retains heat.