Identifying the factors and their interactive effects on soil heavy metals (HMs) accumulation in karst areas is a significant challenge in preventing and controlling soil contamination by HMs. A total of 1043 topsoil (0–20 cm) samples were collected from northwestern Guizhou to determine the concentrations of HMs (Cd, Pb, Zn, Cr, Cu, and Ni). Then, the optimal parameter based geographic detector (OPGD) model was used to identify the driving factors and interactions of natural variables (such as strata, soil organic matter, terrain, etc.) and human activity variables (such as distance from mining sites (DFM), distance from road (DFR), population density (DOP), etc.) on the spatial accumulation of soil HMs in the region. The findings revealed that the average concentrations of all HMs exceeded the corresponding background values of soil in Guizhou Province. Cd had the highest accumulation, followed by Cu, Ni, and Cr. Moran's I and inverse distance interpolation results showed clear clustering trends in the spatial distribution of HMs. The high-high clusters of Cd, Pb, and Zn were concentrated in the northern and southern parts of the study area, while the high-high clusters of Ni, Cr, and Cu were distributed mainly in the eastern and western parts of the study area. OPGD analysis results indicated that soil Cd, Pb, and Zn accumulation was influenced primarily by SOM, DFM, and stratigraphic distribution, followed by pH and soil type. Whereas Ni, Cr, and Cu were mainly affected by stratigraphic distribution. Additionally, DOP, terrain, and soil type were secondary factors affecting the accumulation of these three types of HMs. Notably, the interactive effects among these factors were found to have a more significant impact on HMs accumulation than individual factors alone. Overall, this study provides valuable insights into the main factors influencing the spatial distribution of HMs and their interactive relationships, contributing to the theoretical basis for preventing and controlling HMs pollution in the study area.