Phase change materials (PCMs) have garnered significant attention in the realm of smart buildings due to their transformative impact on building structures and energy efficiency. In the context of smart buildings, incorporating PCMs into construction elements, such as walls or ceilings, enables them to act as thermal energy storage units. This dynamic thermal behavior helps regulate indoor temperatures by absorbing excess heat during warmer periods and releasing it when the environment cools. As a result, smart buildings equipped with PCM technologies exhibit enhanced energy efficiency, reduced reliance on traditional heating, ventilation, and air conditioning (HVAC) systems and a more sustainable overall operation. Using EnergyPlus numerical simulation and a novel hybrid multilevel particle swarm optimization and convolutional neural network (H-MPSO-CNN) model, the performance of PCM in walls and ceilings of Namangan, Uzbekistan and Najran, Saudi Arabia climates was investigated in this study. The study assessed the impact of variables such as melting temperature and optimal location of PCM on heating and cooling load consumption. The results showed that PCM with melting temperatures of 23°C and 25°C had the greatest impact in the Namangan climate, while PCM with a temperature of 25°C had the greatest impact in Najran. The study also determined the best location for PCM on walls and roofs. It was determined that such a system is better suited to Najran’s hot and dry climate. Heating and cooling loads in Namangan can be reduced by 12.39 and 16.01%, respectively, by installing PCM systems in the building’s roof and walls. Similarly, a single-layer PCM system in Najran can reduce heating and cooling energy consumption by 9.97 and 12.11%, respectively. The goal of this study was to reduce the number of hours when the building was not thermally comfortable and to optimize heating and cooling load consumption.