Flipping two fair coins probability function $4$ Consider flipping two fair coins. Let $X = 1$ if the first coin is heads, and $X = 0$
if the first coin is tails. Let $Y = 1$ if the two coins show the same thing (i.e., both heads
or both tails), with $Y = 0$ otherwise. Let $Z = X + Y$, and $W = XY$.
(a) What is the probability function of $Z$?

Attempt:
$P(X = 1) = 1/2$
$P(X = 0) = 1/2$
$P(Y = 1) = 1/2$ since {HH, TT, TH, HT}, 2/4 times.
$P(Y = 0) = 1/2$ (not sure bout this)
(a)
Given $X = 1$, $Z = 2,1$
Given $X = 0$, $Z = 1, 0$
$P(Z = 2) = P(X = 1) + P(Y = 1) = 1/2 + 1/2 = 1$ [Book's answer is 1/4]
$P(Z = 1) = P(X = 1) + P(Y = 0) + P(X = 0) + P(Y = 1) = 2$ [1/2 book]
$P(Z = 0) = P(X = 0) + P(Y = 0) = 1$ [1/4 book]
Could someone explain to me why they multiply instead of adding them? Thanks
 A: This is an answer, since i need to plug in a table...
The modeling probability space has four elements / atoms, in notation HH, HT, TH, TT. (The atoms are the the one element sets for the one or the other outcome of a single two-coins-toss.) Then:
$$
\begin{array}{|r||cccc|}
\hline
 & X & Y & Z & W\\\hline
HH & 1 & 1 & 2 & 1\\
HT & 1 & 0 & 1 & 0\\
TH & 0 & 0 & 0 & 0\\
TT & 0 & 1 & 1 & 0\\\hline
\end{array}
$$
So we get $Z=2$ only in the one case, the first one. "Each row shows" with same probability, $1/4$. 
The error is in the line where instead of the dot in
$P(Z=2)=P(X=1\text{ and }Y=1)=P(X=1)\cdot P(Y=1)$ there is a plus. (The dot is correct since in the model $X,Y$ are independent.)
A: Your calculations have $P(Z=1)=2$ but probabilities cannot exceed $1$.  Indeed $P(Z=2)+P(Z=1)+P(Z=0)=1$ since there is no other possibility
You multiply the probabilities of independent events to get the joint probability since you need both to happen.  You add the probabilities of mutually exclusive event to get the probability that either of them happen
You might find it easier to get the book's results by considering there four possible mutually exclusive events, each row in this table 
Probability 1st coin  2nd coin  X   Y  Z=X+Y W=X*Y
    1/4        H          H     1   1    2    1
    1/4        H          T     1   0    1    0
    1/4        T          T     0   1    1    0
    1/4        T          H     0   0    0    0

So for example $P(Z=2)=\frac14$, $P(Z=1)= \frac14+\frac14$, $P(Z=0)= \frac14$
A: You're on the right track. You can case out the whole function since there are only four cases.
\begin{array}{|c|c|c|c|c|c|}
\hline
Coin 1& Coin 2 & X & Y & Z & W \\ \hline
H & H & 1 & 1 & 2 & 1\\ \hline
H & T & 1 & 0 & 1 & 0\\ \hline
T & H & 0 & 0 & 0 & 0\\ \hline
T & T & 0 & 1 & 1 & 0\\ \hline
\end{array}
Note that $P(Z) \not= P(X) + P(Y)$
