If $X$ and $Y$ are random variables (defined on the same probability space: ignore this remark if it confuses you), then we can regard $(X,Y)$ as a random vector (also called a bivariate random variable) and $X$ and $Y$ individually as special kinds of functions of $(X,Y)$ -- called projections or projection maps if you want to use fancy words. Another function of $(X,Y)$ is $X+Y$ (called the "sum" function, of course, what else?) and what this means is that if on a particular trial of the experiment, $X$ and $Y$ took on values $x$ and $y$ respectively (equivalently, $(X,Y)$ had value $(x,y)$), then this sum random variable (denote it by $Z$) has taken on value $x+y$ on this particular trial. There is no notion of "both occurring"; as whuber points out in his comment, you are confusing the concepts of events and random variables.
So, if $W$ is a random variable, what is $E[g(W)]$, the expected value of the function $V = g(W)$ of the random variable $W$? There are two standard ways of finding the answer: if we know, or can determine,
the distribution of $V$, then we can use the definition of expectation. For example, if $V$ is a continuous random variable with pdf $f_V(v)$, then $$E[V] = \int_{-\infty}^\infty v\cdot f_V(v) \,\mathrm dv.$$
Alternatvely, we can use the
Law of the Unconscious Statistician
or LOTUS and determine the value of $E[V]=E[g(W)]$ as
$$E[V]=E[g(W)] = \int_{-\infty}^\infty g(w)\cdot f_W(w) \,\mathrm dw$$
where $f_W(w)$ is the pdf of $W$. Now, LOTUS applies to functions
of bivariate (and more generally multivariate) random variables also,
and we can find $E[Z] =E[X+Y]$ via
$$E[Z]=E[X+Y] = \int_{-\infty}^\infty \int_{-\infty}^\infty (x+y)\cdot f_{X,Y}(x,y) \,\mathrm dx \,\mathrm dy\tag{1}$$ where $f_{X,Y}(x,y)$ is
the joint pdf of $X$ and $Y$ or just the pdf of the bivariate
random variable $(X,Y)$. As a special case, when $X$ and $Y$ are
independent random variables, $f_{X,Y}(x,y) = f_{X}(x)f_{Y}(y)$ for all $x$ and $y$, and so we get the formula shown in your question. But
it is very important that you understand that $(1)$ always holds, regardless of independence etc (for jointly continuous random variables).
A funny thing happens on the way to the forum as one massages the forumula $(1)$. We have that
\begin{align}
E[X+Y] &= \int_{-\infty}^\infty \int_{-\infty}^\infty (x+y)\cdot f_{X,Y}(x,y) \,\mathrm dx \,\mathrm dy\\
&= \int_{-\infty}^\infty \int_{-\infty}^\infty x\cdot f_{X,Y}(x,y) \,\mathrm dx \,\mathrm dy + \int_{-\infty}^\infty \int_{-\infty}^\infty y \cdot f_{X,Y}(x,y) \,\mathrm dx \,\mathrm dy\\
&= \int_{-\infty}^\infty x\int_{-\infty}^\infty f_{X,Y}(x,y) \,\mathrm dy \,\mathrm dx + \int_{-\infty}^\infty y \int_{-\infty}^\infty f_{X,Y}(x,y) \,\mathrm dx \,\mathrm dy\\
&= \int_{-\infty}^\infty x\left[\int_{-\infty}^\infty f_{X,Y}(x,y) \,\mathrm dy \right] \,\mathrm dx + \int_{-\infty}^\infty y \left[\int_{-\infty}^\infty f_{X,Y}(x,y) \,\mathrm dx\right] \,\mathrm dy\\
&= \int_{-\infty}^\infty x \cdot f_{X}(x) \,\mathrm dx + \int_{-\infty}^\infty y\cdot f_{Y}(y) \,\mathrm dy\\
E[X+Y] &= E[X] + E[Y]\tag{2}
\end{align}
The result $(2)$ is a special case of the linearity of expectation
because the argument above can be applied to show that $E[aX+bY] = aE[X]+bE[Y]$, that is, expectation behaves like a linear operation
with respect to random variables: the expectation of a weighted sum
is the weighted sum of the expectations.
Linearity of expectation is a very general result. It holds for all
random variables, not just the jointly continuous ones as in the calculation above, or for independent random variables only as the answer by Stefan Jorgenson seems to be suggesting.