From your assumptions it follows that $A$, $B$, and hence also $\text{adj}(AB)$ and $\text{adj}(BA)$ are invertible. Just apply determinant to the equation $AB\cdot\text{adj}(BA)=I$, and use the fact $M\text{adj}M=\det(M)I$.
Moreover, the assumption implies $$ (\text{adj}(BA))^{-1} = AB. $$ On the other hand using $M\text{adj}M=\det(M)I$ we find $$ (\text{adj}(BA))^{-1} = (\det(BA))^{-1} BA $$ This implies $$ \det(BA)AB = BA. $$ Applying determinant to this equation yields $\det(BA)=1$, which gives and $AB=BA$.