Joint probability vs marginal probability - understanding the integration limits Can i pick your brains about this?

My goal was to calculate $E[X]$, $E[Y]$ and E[XY] (with the end goal of computing covariance but that's not important for this query).
It was when I tried to calculate $f_Y(y)$ that i realized I didn't understand the integration limits when we calculate $E[XY]$. Please observe the two limits for the $x$ variation.
For $f_Y(y)$:

For the $E[XY]$:

I suspect because both variables are changing together we can do this but I don't have intuition for it or a rigorous explanation for why this difference is there. $0\to{1}$ vs $0\to{y}\cup{y-1\to{1}$.
Thank you in advance!
 A: It looks like the support is the paralellogram $\langle 0,0\rangle\langle 1,1\rangle\langle 1,2\rangle\langle 0,1\rangle$
As such, the marginal density for $Y$ shall be a piecewise function, not a sum.  Look at the graph and see how the bounds of the horizontal cross-section depend upon the height.
$\qquad f_{\small Y}(y)=\begin{cases}\int\limits_0^{y} f_{\small X,Y}(x,y)\,\mathrm d x&:& 0\leq y\lt 1\\[1ex]\int\limits_{y-1}^1 f_{\small X,Y}(x,y)\,\mathrm d x&:& 1\leq y\leq 2\\[1ex]0&:&\textrm{otherwise}\end{cases}$
However, for the expectation you will be summing over all the pieces of the marginal's domain, so you shall have:
$\qquad\begin{align}\mathsf E(Y) &= \int_0^1 y~f_{\small Y}(y)\,\mathrm d y\\&=\int_0^1 y\int_0^y f_{\small X,Y}(x,y)\,\mathrm d x\,\mathrm d y+\int_1^2 y\int_{y-1}^1 f_{\small X,Y}(x,y)\,\mathrm d x\,\mathrm d y\end{align}$
You should now be able to find expressions for $\mathsf E(X)$ and $\mathsf E(XY)$.

BTW: The marginal density for $X$ is indeed :
$\qquad f_{\small X}(x)=\begin{cases}\int\limits_x^{x+1} f_{\small X,Y}(x,y)\,\mathrm d y&:& 0\leq x\leq 1\\[1ex]0&:&\textrm{otherwise}\end{cases}$
However, this should not be used to calculate $\mathsf E(\color{red}Y)$.   Please, use it for $\mathsf E(X)$ ...
