I have grappled with this question myself, and here is what I came up with.
Holomorphic functions are highly constrained. A priori, all we know is that they must satisfy the Cauchy–Riemann equations, but by doing a little math we see that that infinitesimal constraint propagates outward into local and even global constraints. This propagation is, to be sure, a miracle. But it is one with which we are familiar in math. The Mean Value Theorem, the Fundamental Theorem of Calculus, and Green’s theorem are each examples of this miracle. You might later learn about harmonic functions, which are so highly constrained that their behavior along a boundary can actually completely determine what they do inside a region.
That is the explanation for why such a result is plausible. As for what is actually going on numerically—what you would actually see if you could graph a holomorphic function in four dimensions: whatever is gained somewhere along $\gamma$ must be forfeited somewhere else along $\gamma$. That is because what happens along one part of $\gamma$ is actually not independent of what happens along the other part of $\gamma$. The reason for that is that the piece of the graph of $f$ which lies along $\gamma$ is the boundary of a sheet of rubber, and hence can’t be contorted arbitrarily. Bounding a sheet really is the key property, because when it fails, i.e., when that sheet is punctured, i.e., when $f$ has a pole in the region of which $\gamma$ is the boundary, this is precisely when the given integral can fail to be zero.
Now, if you want to really understand mathematically what’s going on, you have to understand the proof of either Green’s theorem or Stokes’s theorem. Cauchy is a direct consequence of Green (using the Cauchy–Riemann equations), and Stokes is a more general formulation of Green.