Addition of two piecewise function Suppose I have function 

$$y(x)=\begin{cases}
 x+1\qquad & 0\leq x\leq1 \\
 2-x\qquad &  1<x \leq2 \\
0\qquad & \mathrm{elsewhere}
\end{cases}$$
  I need to find the function $g(x)=y(x+2)+2y(x+1)$


$$y(x+2)=\begin{cases}
 x+3\qquad &-2\leq x\leq-1 \\
 -x\qquad &  -1<x \leq0 \\
0\qquad &\mathrm{elsewhere}
\end{cases}$$
$$2y(x+1)=\begin{cases}
 2x+4\qquad & -1\leq x\leq0\\
 2-2x\qquad &  0<x \leq1 \\
0\qquad &\mathrm{elsewhere}
\end{cases}$$
Now,
$$g(x)=y(x+2)+2y(x+1)=\begin{cases}
 x+3\qquad & -2\leq x\leq -1 \\
 x+4\qquad &  -1<x \leq0 \\
2-2x\qquad &0<x\leq1\\
0\qquad &\mathrm{elsewhere}
\end{cases}$$
Now the result looks Okay,
But the problem is the value of $y(x+2)$ at $x=-1$ is $2$ and $2y(x+2)$ at $x=-1$ is also $2$ so if I add both then $y(x+2)+2y(x+1)$ at $x=-1$ will be $2+2=4$,but the value of $g(x)$ at $x=-1$ is $-1+3=2$ 

In your calculation of $g(x)$, the first line, $x+3$, was obtained by adding $y(x+2)=x+3$ and $2y(x+1)=0$.  The first of these two equations, $y(x+2)=x+3$, is valid for $x$ in the range $-2\leq x\leq-1$. The second, $2y(x+1)=0$, is valid when $x<-1$ and also when $x>1$. In particular, it is not valid when $x=-1$.  So the $x+3$ line in your formula for $g(x)$ is not valid for $x=-1$ but only for $-2\leq x<-1$.  
More generally, when you combine several formulas, each f which is valid for a certain range of $x$ values, then the combination will in general only be valid for those $x$ values that are in all the relevant ranges simultaneously.  
