The effects of alloying elements Ti, Zr, Ta, and W on the thermodynamic and mechanical properties of HfC were investigated at temperatures ranging from 0 to 3000 K and pressures from 0 to 100 GPa using first-principles calculations and quasi-harmonic approximate Debye model. The results show that Ti and W decrease the thermal expansion coefficient of HfC at elevated temperatures, while Ta and Zr increase this coefficient. In terms of melting point, Ti and Zr lower the melting temperature of HfC, whereas Ta and W raise it. All four alloying elements enhance the Debye temperature of HfC at elevated temperatures and higher pressures. Their impact on heat capacity is negligible at high temperatures, but results in a reduction at high pressures. In terms of elastic properties, Zr reduces the elastic modulus of HfC, while Ta and W significantly enhance it. Additionally, at high temperatures, Ti weakens the elastic anisotropy of HfC, while Zr and Ta enhance it; the effect of W is small. At high pressures, however, the influence of the alloying elements on the elastic anisotropy of HfC is relatively weak.