In order for $K_X$ to exist you need some restriction on the singularities of $X$. See thisthis MO answer for some thoughts on that. The most usual assumption to make is that $X$ is normal which implies that it is non-singular in codimension $1$.
In order to pull-back $K_X$ and still get a divisor, you need something more, the usual assumption is that it should be $\mathbb Q$-Cartier. See thisthis MO answer for more on that.
If you have that $X$ and $Y$ are non-singular in codimension $1$, then you can forget about the second condition and just consider the formula on the non-singular part. (Strictly speaking you would want to restrict to the complement of the image of the singular part of $X$ on $Y$ so you'd still have a finite map).
So, let's say that both $X$ and $Y$ are smooth and $\pi$ is finite. Then localizing at height $1$ primes (or codimension $1$ points) reduces the statement to curves. Albeit not over the original field, but it's still OK.
I think this should cover two of your questions.