Each entry of the matrix is given by the row number $i$ and the column number $j$, and we say that $(i,j)$ is the index of this entry. Notice that the $k$-th diagonal is defined by $(i,j)$-entries with $i+j=k+1$. Since $i\in\{1,2,\ldots,M\}$ and $j\in\{1,2,\ldots,N\}$, we see that
$$k=i+j-1\in\{1,2,\ldots,M+N-1\}\,.$$
Each $k\in\{1,2,\ldots,M+N-1\}$ corresponds to a nonempty diagonal line. For $k=1,2,\ldots,M$, the $k$-th diagonal contains the entry indexed by $(k-1,1)$. For $k=M+1,M+2,\ldots,M+N-1$, the $k$-th diagonal contains the entry indexed by $(M,k+1-M)$.