Titanium carbide (TiC), tantalum carbide (TaC) and zirconium carbide (ZrC) in form of particles are widely added in W to improve its mechanical and anti-irradiation properties. However, TiC, TaC and ZrC particles are decomposed to Ti-C-O, Ta-C-O and Zr-C-O in W, respectively. To understand the micro-mechanisms, we carry out systematical simulations and find that the presence of impurities such as O, N, and P has great influence on the bond length and bond strength of Ti-C, Ta-C and Zr-C in W. The bond lengths of Ti-C, Ta-C and Zr-C are generally increased when O meets Ti-C, Ta-C and Zr-C. The bond strength of O to Ti-C, Ta-C and Zr-C is much larger than that of C to Ti-O, Ta-O and Zr-O. In contrast, N has little effect on the Ti-C bond, but has great influence on the Ta-C bond. P significantly increases Ta-C bond length, while its influence on Zr-C bond is negligible. The kinetics calculations elucidate that the diffusion barriers of C away from TiO are significantly increased by about 1 eV. It is very difficult for C to escape from TiO and ZrO, and it is also extremely difficult for O to escape from TiC, TaC and ZrC. This may be the reason why Ti-C-O, Ta-C-O, and Zr-C-O particles are found in W when TiC TaC and ZrC compounds are dispersed in W.