Accurately identifying pollution risks and sources is crucial for regional land resource management. This study takes a certain coastal county in eastern China as the object to explore the spatial distribution, pollution risk, and source apportionment of heavy metals in topsoil. A total of 633 samples were collected from the topsoil with a depth ranging from 0 to 20 cm, which came from different topographical and land use types (e.g., farmland, industrial areas, and mining areas), and the concentrations of HMs and As were measured by using atomic fluorescence spectrometry and inductively coupled plasma mass spectrometry. Firstly, the spatial distribution of soil HMs (Cd, Cr, Hg, Ni, and Pb) and arsenic (As) was predicted by incorporating environmental variables strongly affecting soil formation into geostatistical methods and machine learning approaches. Then, various pollution indicators were employed to conduct pollution evaluations, and potential ecological risk assessments were implemented based on the generated soil map. Finally, source apportionment was conducted using random forest (RF), absolute principal component score–multiple linear regression (APCS-MLR), correlation analysis, and spatial distribution of soil HMs and As. Findings in this research reveal that the RF approach yielded the best spatial prediction performance (0.59 ≤ R2 ≤ 0.73). The Nemerow and geoaccumulation indices suggest that various pollution levels exist in this area. The average concentrations of As, Hg, and Ni are 7.233 mg/kg, 0.051 mg/kg, and 27.43 mg/kg respectively, being 1.14 times, 1.27 times, and 1.15 times higher than the background levels, respectively. The central–northern region presented a slight potential ecological risk, with Hg and Cd being identified as the primary risk factors. Natural, agricultural, transportation, and industrial and mining activities were identified as the main HMs and As sources. These findings will assist in the design of targeted policies to reduce the risks of HMs and As in urban soil and offer useful guidelines for soil pollution research in similar regions.