Microelectromechanical system and nanoelectromechanical system (MEMS and NEMS) transistors are considered promising for size-reducing and power-maximizing electronic devices. However, the tribopolymer which forms due to the mechanical load to the contacts affects the conductivity dramatically. This is one of the challenging problems that prevents the widespread practical use of these otherwise promising devices. Here, we use density functional theory (DFT) to investigate the mechanisms of tribopolymer formation, including normal mechanical load and the catalytic effect, as well as the electrochemical effect of the metal contacts. We select benzene as the background gas, because it is one of the most common and severe hydrocarbon contaminants. Two adsorption cases are considered: one is benzene on the reactive metal surface, Pt(111), and the other is benzene on the noble metal, Au(111). We demonstrate that the formation of tribopolymer is induced by both the mechanical load and the catalytic effect of the contact. First, benzene molecules are adsorbed on the Pt surfaces. Then, due to the closure of the Pt contacts, stress is applied to the adsorbates, making the C-H bonds more fragile. As the stress increases further, H atoms are pressed close to the Pt substrate and begin to bond with Pt atoms. Thus, Pt acts as a catalyst, accelerating the dehydrogenation process. When there is voltage applied across the contacts, the catalytic effect is enhanced by electrochemistry. Finally, due to the loss of H atoms, C atoms become more reactive and link together or pile up to form tribopolymer. By understanding these mechanisms, we provide guidance on designing strategies for suppressing tribopolymer formation.