First, let us prove a related numerical lemma.
Lemma: Let $n\in \mathbb N$, let $x_1,\dots,x_n$ be real numbers between $0$ and $1$, and let $m$ be a positive integer for which $m\le n$. For integers $k,r$ such that $1\le k\le r$, Let $e^r_k$ denote the $k^\text{th}$ elementary symmetric polynomial in $r$ variables evaluated at the first $r$ numbers $x_1,\dots,x_r$. That is,
$$ e^r_k=\sum_{1\le i_1<i_2<\dots<i_k\le r}x_{i_1}x_{i_2}\cdots x_{i_k}$$
Furthermore, define $e^r_0=1$, and $e^r_{-1}=0$ for any $r\ge 0$. Then
$$(-1)^m\prod_{i=1}^n(1-x_i)\le (-1)^m\sum_{k=0}^m e^n_k$$
Proof: We prove this by induction on $n$.
\begin{align}(-1)^m\prod_{i=1}^n (1-x_i)
&= (-1)^m\prod_{i=1}^{n-1}(1-x_i)+(-1)^{m-1}x_n\prod_{i=1}^{n-1}(1-x_i)\\
&\le (-1)^m\sum_{k=0}^m (-1)^ke_{k}^{n-1}+(-1)^{m-1}x_n \sum_{k=0}^{m-1}(-1)^ke_{k}^{n-1}\\
&= (-1)^m\sum_{k=0}^m (-1)^k\big(e_{k}^{n-1}+x_n e_{k-1}^{n-1}\big)\\
&= (-1)^m\sum_{k=0}^m (-1)^ke_{k}^{n}\end{align}
For the second step, we apply the induction hypothesis twice. In the last step, we use the rule $$e^{n}_k=e^{n-1}_k+x_{n}\cdot e^{n-1}_{k-1},$$ which is analogous to Pascal's rule, and is proven in the same way; take the summands defining $e^n_k$, and split them into groups, based on whether they have $x_n$ as a factor.
With this lemma, the Bonferroni inequalities are easy to derive. Let $X_i={\bf 1}(A_i)$ be the indicator random variable for $A_i$. From the Lemma,
$$
(-1)^m\prod_{i=1}^n (1-X_i)\le (-1)^m \sum_{k=0}^m e^n_k(X_1,\dots,X_n)
$$
If we negate both sides of this inequality, then add $(-1)^m$ of both sides, we get
$$
(-1)^m\left[1-\prod_{i=1}^n (1-X_i)\right]\ge (-1)^m\sum_{k=\color{red}1}^me^n_k(X_1,\dots,X_n),
$$
since $e^n_0(X_1,\dots,X_n)=1$. Finally, take the expected value of both sides.
On the LHS, note that $\left[1-\prod_{i=1}^n (1-X_i)\right]$ is exactly the indicator random variable for $\bigcup_{i=1}^n A_i$.
On the RHS, it is easy to see that the expected value of $e^n_k(X_1,\dots,X_n)$ is just $S_k$.
Thus, we have proved that
$$
(-1)^mP\left(\bigcup_{i=1}^n A_i\right)\ge (-1)^m \sum_{k=1}^m S_k
$$
For each $m$, this is exactly the $m^\text{th}$ Bonferroni inequality; the effect of the $(-1)^m$ is to switch the direction of the inequality when $m$ is odd.