Let $X, Y$ be independent random variables, both uniformly distributed over the interval $(0,1)$. That is, $$f_{X}(a)=f_{Y}(a) = \begin{cases} 1 & \text{if $0 < a < 1$} \\ 0 & \text{otherwise} \end{cases}$$ Find $f_{X+Y}(a)$.
In my probability course, the solution to this problem was given as follows, but figuring out the integrals was very much "by inspection", and for this one, particular problem.
$$ f_{X+Y}(a) = \begin{cases} \int_{0}^{a} dy = a & \text{if $0 < a < 1$} \\\int_{a-1}^{1} dy = 2 - a & \text{if $1 < a < 2$} \end{cases}$$
It's not so apparent to me how we know these are the correct integration bounds in these two cases. I want a general, straightforward way to figure out exactly which integrals need to be computed for probability problems of this kind. So I read this answer by André Nicolas, which it finally made it clear to me how to start finding $P(X+Y \le a)$:
Another way: (Sketch) We can go after the cdf $F_Z(z)$ of $Z$, and then differentiate. So we need to find $\Pr(Z\le z)$.
For fixed $z$, draw the line with equation $x+y=z$. Draw the square $S$ with corners $(0,0)$, $(1,0)$, $(1,1)$, and $(0,1)$.
Then $\Pr(Z\le z)$ is the area of the part $S$ that is "below" the line $x+y=z$. That area can be calculated using basic geometry. There is a switch in basic shape at $z=1$.
Then by drawing a figure with a square with vertices $(0,0), (0, 1), (1,0), (1,1)$, I come up with the following two integrals:
$$ \small P(X+Y \le a) = \int_{0}^{1} \left( \int_{0}^{a-y} f(x) \ \mathrm{d} x \right) f(y) \ \mathrm{d}y = \int_{0}^{1} \left( a-y \right )1 \ \mathrm{d}y = a - \frac{1}{2} \ \ \ \ \ \text{if $0 < a < 1$} $$
$$ \small P(X+Y \le a) = \int_{0}^{1} \left( \int_{1-y}^{a-y} f(x) \ \mathrm{d} x \right) f(y) \ \mathrm{d}y = \int_{0}^{1} \left( (a-y) - (1 - y) \right )1 \ \mathrm{d}y = \int_{0}^{1} (a - 1) \ \mathrm{d}y \ \ \ \text{if $1 < a < 2$} $$
It appears that I have made a mistake somewhere, since $\frac{d}{\mathrm{d}\ a}\left(F_{X+Y}(a) \right) =\frac{d}{\mathrm{d}\ a}\left( P(X+Y\le a) \right) = f_{X+Y}(a)$ in neither case gives me the correct answer for $f_{X+Y}(a)$.
Please help me see my mistake; what am I missing?