If $Y=X^TX$ is invertible, then clearly
$$
(X^TX)(X^TX)^{-1}=YY^{-1}=I
$$
is the identity matrix.
You might refer instead to $(X^TX)^{-1}X^T$, which is a particular left inverse of $X$, because
$$
\bigl((X^TX)^{-1}X^T\bigr)X=(X^TX)^{-1}(X^TX)=I
$$
This has a name: it is the Moore-Penrose pseudoinverse of $X$ (it's a very particular case). Proving the properties that show it is indeed the pseudoinverse is easy.
If $Y=X^TX$ is invertible, then clearly $$ (X^TX)(X^TX)^{-1}=YY^{-1}=I $$ is the identity matrix.
You might refer instead to $(X^TX)^{-1}X^T$, which is a particular left inverse of $X$, because $$ \bigl((X^TX)^{-1}X^T\bigr)X=(X^TX)^{-1}(X^TX)=I $$ This has a name: it is the Moore-Penrose pseudoinverse of $X$ (it's a very particular case). Proving the properties that show it is indeed the pseudoinverse is easy.