The air at the top of a mountain is not hot air that has risen from the bottom of the mountain and, without any loss of heat to the surrounding, reached the top.
The reason behind air at the top of the mountain being cooler than it is at a lower altitude is the decrease in air pressure as the altitude increases. A packet of air of the same mass placed at sea level is compressed due to a higher pressure and occupies a small volume. At the altitude is increased the pressure falls and with it the volume of the same packet of air increases. The process that takes place here is an adiabatic process that does not involve any heat energy entering or exiting the packet. As volume is increased in an adiabatic process there is a drop in the temperature.
This explains why air at the top of a mountain is cooler. There is no heating of the air here due to the hot air rising from the bottom.