$$\mathbf{1}_A = \begin{cases} 1 & \text{if } A \text{ occurs} \\ 0 & \text{otherwise} \end{cases}, \qquad E[\mathbf{1}_A] = P(A)$$
Attach a $0/1$ variable to each event so that summing the variables counts how many events occur, and its expectation is just the probability.