During the development of shale gas, one of the major challenges is the casing deformation (CD) in the horizontal section due to the geological activity. Recently, the casing deformation before hydraulic fracturing (CDBF) occurred in multiple shale gas wells in L block in China. In this paper, based on the theory of tubular mechanics, the relationship between casing buckling and CDBF caused by casing running in is analyzed qualitatively and quantitatively. It is found that the buckling deformation caused by running the casing string process is not sufficient to prevent the tool (Φ99 mm bridge plug). On the other hand, the mechanism of CDBF is systematically analyzed based on the actual field data and finite element (FE) method. In order to analyze the CDBF mechanism, the comparison between the actual casing trajectory and the reservoir rock (S#1, S#2, S#3 and M#1) in horizontal section in H2 platform is carried out, and the preliminary CDBF mechanism is proposed. Then, two groups of FE models are established to reduce the CD process to verify the preliminary mechanism. It is found that the numerical simulation results (high stress section length from FE model) are in good agreement with the actual CD logging results. Based on the analytical results, the corresponding mitigation measures are proposed based on the analysis of the CDBF mechanism. Our work could offer a detailed theoretical basis and reference of CDBF for shale gas well application.