The MAX phase has attracted much attention due to its unique properties combined with the merits of both metal and ceramic, including the low density, high electrical conductivity and good oxidation resistance, which makes it significant for possible applications in various high temperature or other environments. There is a lot of research work on Ti2AlX (X=C, N). However little research about thermodynamic properties at high pressure is carried out. So we study the structural, mechanical and thermodynamic properties of Ti2AlC and Ti2AlN at various pressures and temperatures. The first-principles calculations based on electronic density-functional theory framework are used to investigate the properties at various pressures. The cut-off energy is 350 eV. Converged results are achieved with 10102 special K-point meshes. The self-consistent convergence of total energy is set to be 5.010-6 eV/atom. According to the calculated structural parameters at various pressures, we can find that the ratios V/V0 (V0 denotes the system volume at 0 GPa) of Ti2AlX are reduced by 20.59% and 18.93%, respectively, so the compressibility of the system is strong. As the internal pressure increases, the curves of V/V0 become gentle. Then we calculate elastic constants at pressures ranging from 0 to 50 GPa in steps of 10 GPa. It is obvious that the Ti2AlX is mechanically stable because all of the elastic constants satisfy the Born stability criteria. The bulk modulus, shear modulus and Young's modulus linearly increase with internal pressure increasing, implying that the pressure can improve the resistance to volume deformation. The ductility and brittleness can be judged according to Pugh's criterion (ratio of bulk modulus to shear modulus B/G), and the brittle nature turns into ductile nature in a pressure range of 40-50 GPa for the Ti2AlX since the value of B/G exceeds 1.75. Finally, we study the thermodynamic properties at various pressures and temperatures based on the quasi-harmonic Debye approximation theory, including the bulk modulus, heat capacity and thermal expansion coefficient. The bulk modulus decreases with temperature increasing but increases with pressure increasing. The heat capacity at constant volume Cv and the heat capacity at constant pressure Cp have the same variation tendency, while Cv obeys the Dulong-Petit limit. It is easy to see that temperature and pressure have opposite influences on heat capacity and the effect of temperature is more significant than that of pressure. The effects of temperature and pressure on linear expansion coefficient mainly occur at low temperature and the effect of pressure is not so considerable when the pressure exceeds 30 GPa. Above all, the effects of temperature and pressure on thermodynamic properties are inverse.