Coal matrix deformation is one of the main controlling factors for coal reservoir permeability changes in nitrogen foam fracturing. The characteristics and mechanism of coal matrix deformation during the process of adsorption/desorption were studied by isothermal adsorption/desorption experiments with methane and nitrogen. Based on the free-energy theories, the Langmuir equation, and elastic mechanics, mathematical models of coal matrix deformation were developed and the deformation characteristics in adsorption/desorption processes were examined. From the study, we deduced that the coal matrix swelling, caused by methane adsorption, was a Langmuir-type relationship with the gas pressure, and exponentially increased as the adsorption quantity increased. Then, the deformation rate and amplitude of the coal matrix decreased gradually with the increase of the pressure. At the following stage, where nitrogen replaces methane, the coal matrix swelling continued but the deformation amplitude decreased, which was only 19.60% of the methane adsorption stage. At the mixed gas desorption stage, the coal matrix shrank with the reduction of pressure and the shrinkage amount changed logarithmically with the pressure, which had the hysteresis effect when compared with the swelling in adsorption. The mechanism of coal matrix deformation was discussed through a comparison of the change of micropores, mesopores, and also part macropores in the adsorption process.