In general, for a given random variable $X : \Omega \rightarrow \mathbb{R}$, the expectation is defined as $$ E[X] := \int_\Omega X dP, $$ where $P$ is a probability measure on $\Omega$. For discrete RVs, there's a simpler definition for the expectation, namely $$ E[X] := \sum_{x \in X(\Omega)}x P[X=x]. $$ Obviously the first definition should coincide with the second one if $X$ is discrete. If $X$ is simple (i.e. takes on only finitely many values), the result follows immediately from the definition of the Lebesgue integral on simple functions. However, if $X$ takes on (countable) infinitely many values (e.g. $X$ is a geometrically distributed), then it's not clear to me how one arrives at the 2nd definition, given the 1st one. In that case we get $$E[X] = \sup\{ \int_\Omega Y dP \mid \text{$Y$ is simple and $Y\leq X$} \},$$ but I couldn't see why this is equivalent to the infinite sum.
If $Y$ is non-negative, discrete, and integrable, let $\{y_n\}_{n=1}^{+\infty}$ the values taken by $Y$. Define $S_N:=\sum_{n=1}^Ny_n\chi_{Y^{-1}\{y_n\}}$: it's a simple function, and $0\leq S_N\leq Y$. So $E[Y]\geq \sum_{n=1}^Ny_nP(Y=y_n)$ for all $N$, which gives $E[Y]\geq \sum_{n=1}^{+\infty}y_nP(Y=y_n)$. We can apply monotone convergence theorem to get the other direction.