Mud is a bad conductor of heat and so is the air trapped in the thatched roof. In summer the heat from outside is not allowed to flow in and hence it keeps cool. Similarly in winter, the heat from inside does not flow out and it keeps the house warm.