You may count the paths starting horizontally, and multiply the end result by 2 by symmetry. Now consider the sets $S_r,S_c$ of rows and columns that contain at least one turning point, or the start or end point. In general there will be exactly two such points in the row or column as soon as there is one, the exceptions being the first column, and depending on whether $K$ is odd or even the last row or column (these have only one such point). The first and last rows are uninteresting, as they are always in the sets $S_r,S_c$, it suffices to choose the remainder of these sets among the remaining $N-2$ columns/rows.
Now you should be able to figure out why the result is twice $\binom{N-2}i\binom{N-2}{i-1}$ when $K=2i$, and twice $\binom{N-2}i\binom{N-2}i=\binom{N-2}i^2$ when $K=2i+1$. Don't forget the factors 2.