When you make the substitution , we see that
At this stage, let's go back to the original integral:
Observed that I highlighted the part that appeared in our term! So we see that .
Then integrating results in and back substitution gives us the desired result .
Does this clarify what's going on here?