Potato's answer gives you all you need. But I'd like to mention not why these facts are true, but why they should be true. So here's how I like to think about it (all of which can be made precise):
We know that the derivative of the natural log function is $z^{-1}$, so locally the antiderivative of $z^{-1}$ is $\ln$. But since the exponential function is $2\pi i$-periodic, $\ln$ is not well-definied: if we start by defining, say, $\ln(1)$, we have to choose which inverse function to use: should that be $0$, or $2\pi i$, or $-38\pi i$? So we make a choice, and continuing along the unit circle, we define natural log to be the function whose anti-derivative is $z^{-1}$ which is consistent with our original choice. (This can be made precise, and is an example of what is called analytic continuation.) Since the imaginary part of $\ln$ measures argument (angle), an we have been moving in the positive direction the whole time, we see that our function is not consistent: when we get back to $1$ we are $2\pi i$ more than where we started! So although we can locally define $\ln$, we run into trouble trying to define the function on all of $\mathbb{C}\backslash \{0\}$. This same inconsistency, via the fundamental theorem of calculus, explains the residue formula as well: one bound of the integral is given by one choice of $\ln(1)$, and the other bound is evaluated using another choice.