$\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
\newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
\newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
\newcommand{\dd}{\mathrm{d}}
\newcommand{\ds}[1]{\displaystyle{#1}}
\newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
\newcommand{\ic}{\mathrm{i}}
\newcommand{\mc}[1]{\mathcal{#1}}
\newcommand{\mrm}[1]{\mathrm{#1}}
\newcommand{\pars}[1]{\left(\,{#1}\,\right)}
\newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
\newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
\newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
\newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
&\mbox{Lets}\ \mrm{u}_{x}\pars{x,t} =
\sum_{n = 1}^{\infty}a_{n}\pars{t}\sin\pars{nx}\
\mbox{which already satisfies}\
\mrm{u}_{x}\pars{0,t} = \mrm{u}_{x}\pars{\pi,t} = 0.
\\[5mm] &\
\mbox{Then,}\
\mrm{u}\pars{x,t} =
-\sum_{n = 1}^{\infty}a_{n}\pars{t}\,{\cos\pars{nx} \over n} + \mrm{f}\pars{t}.
\\ &\ \mrm{f}\pars{t}\ \mbox{is a time dependent }\ arbitrary\ \mbox{function ( for the time being ).}
\end{align}
$\ds{\mrm{u}\pars{x,t}}$ must satisfy the differential equation. Namely,
\begin{align}
&0 = \bracks{-\sum_{n = 1}^{\infty}\ddot{a}_{n}\pars{t}\,{\cos\pars{nx} \over n} + \ddot{\mrm{f}}\pars{t}} -
\bracks{\sum_{n = 1}^{\infty}a_{n}\pars{t}n\cos\pars{nx}}
\\[5mm] &\ +
2\bracks{-\sum_{n = 1}^{\infty}a_{n}\pars{t}\,{\cos\pars{nx} \over n} + \mrm{f}\pars{t}}
\end{align}
Integrating both sides over
$\ds{\pars{0,\pi}} \implies
\ddot{\mrm{f}}\pars{t} + 2\,\mrm{f}\pars{t} = 0 \implies
\mrm{f}\pars{t} = A\sin\pars{\root{2}t} + B\cos\pars{\root{2}t}$.
$\ds{A\ \mbox{and}\ B}$ are constants.
Similarly, integrate after multiplying both sides for a factor
$\ds{\cos\pars{nx}}$ to get
\begin{align}
&\ddot{a}_{n}\pars{t} + \pars{n^{2} + 2}a_{n}\pars{t} = 0
\\ &\ \implies
a_{n}\pars{t} =
a_{n}\pars{0}\cos\pars{\root{n^{2} + 2}t} +
\dot{a}_{n}\pars{0}\,{\sin\pars{\root{n^{2} + 2}t} \over \root{n^{2} + 2}}
\end{align}
The general solution becomes:
\begin{align}
\mrm{u}\pars{x,t} & =
-\sum_{n = 1}^{\infty}\bracks{a_{n}\pars{0}\cos\pars{\root{n^{2} + 2}t} +
\dot{a}_{n}\pars{0}\,{\sin\pars{\root{n^{2} + 2}t} \over \root{n^{2} + 2}}}\,{\cos\pars{nx} \over n}
\\ & +
A\sin\pars{\root{2}t} + B\cos\pars{\root{2}t}
\end{align}
Also,
$$
0 = \mrm{u}\pars{x,0} =
-\sum_{n = 1}^{\infty}a_{n}\pars{0}\,{\cos\pars{nx} \over n} + B
\implies a_{n}\pars{0} = B = 0
$$
The general solution is reduced to
\begin{align}
\mrm{u}\pars{x,t} & =
-\sum_{n = 1}^{\infty}
\dot{a}_{n}\pars{0}\,{\sin\pars{\root{n^{2} + 2}t} \over \root{n^{2} + 2}}\,{\cos\pars{nx} \over n}
+
A\sin\pars{\root{2}t}
\end{align}
In addition,
\begin{align}
\mrm{u}_{t}\pars{x,0} & = {x \over \pi} =
-\sum_{n = 1}^{\infty}
\dot{a}_{n}\pars{0}\,{\cos\pars{nx} \over n}
+
\root{2}A
\end{align}
Integrating both sides over $\ds{\pars{0,\pi} \implies
{\pi \over 2} = \root{2}A\pi \implies A = {\root{2} \over 4}}$. Also,
\begin{align}
&\int_{0}^{\pi}{x \over \pi}\,\cos\pars{nx}\,\dd x =
-\,{\pi \over 2n}\dot{a}_{n}\pars{0} \implies
{\pars{-1}^{n} - 1 \over n^{2}\pi} = -\,{\pi \over 2n}\dot{a}_{n}\pars{0}
\\[5mm] &\
\implies \dot{a}_{n}\pars{0} =
{2 \over \pi^{2}}\,{1 - \pars{-1}^{n} \over n}
\end{align}
Finally,
\begin{align}
\mrm{u}\pars{x,t} & =
-\sum_{n = 1}^{\infty}
{2 \over \pi^{2}}\,{1 - \pars{-1}^{n} \over n}\,{\sin\pars{\root{n^{2} + 2}t} \over \root{n^{2} + 2}}\,{\cos\pars{nx} \over n}
+
{\root{2} \over 4}\,\sin\pars{\root{2}t}
\\[5mm] & =
\color{red}{-\,{4 \over \pi^{2}}\sum_{n = 0}^{\infty}
{1 \over \pars{2n + 1}^{2}}\,{\sin\pars{\root{\bracks{2n + 1}^{2} + 2}t} \over \root{\bracks{2n + 1}^{2} + 2}}\cos\pars{\bracks{2n + 1}x}}
\\[2mm] &\
\color{red}{+ {\root{2} \over 4}\,\sin\pars{\root{2}t}}
\end{align}
Best Answer
What you need to do is to set $\lambda$ in such a way that the boundary condition is fulfilled. Since your solution should be $2\pi$ periodic in $x$ the choice $\lambda_n=n\in\mathbb{N_0}$ yields actually a family of suitable solutions: $$ v(x,t)=\sum_{i=0}^\infty (A_n \cos{n x} + B_n \sin{n x})(C_ne^{n y}+D_ne^{-n y}) $$ Now we insert the $y$ boundary conditions $$ a\sin(x)=\sum_{i=0}^\infty (A_n \cos{n x} + B_n \sin{n x})(C_n+D_n) $$ which gives $$ C_n+D_n=0 \mbox{ for } n\neq1\\ A_1=0\\ B_1=a\\ C_1+D_1=1 $$ Inserting yields $$ v(x,t)=a\sin(x)(C_1e^{y}+(1-C_1)e^{-y})+\sum_{i\neq1} (A_n \cos{n x} + B_n \sin{n x})(C_ne^{n y}-C_ne^{-n y}) $$
Likewise the second condition gives $$ b\sin(2x)=a\sin(x)(C_1e^{1}+(1-C_1)e^{-1})+\sum_{i\neq1} (A_n \cos{n x} + B_n \sin{n x})(C_ne^{n}-C_ne^{-n}) $$
$$ C_n=0 \mbox{ for } n\neq1,2\\ A_2=0\\ B_2=b\\ C_2e^{2}-C_2e^{-2}=1\\ C_1e^{1}+(1-C_1)e^{-1}=0 $$ which finally gives the solution as: $$ v(x,t)=a\sin(x)\frac{e^{1-y}-e^{y-1}}{e-e^{-1}}+b\sin(2x)\frac{e^{2y}-e^{-2y}}{e^{2}-e^{-2}} $$
Note that for this specific example of $y$ boundary conditions the full family of solutions was not necessary it would have been sufficient to just take the sum of the two needed functions ($\lambda\in\{1,2\}$ and only the sine functions). However the presented methods also works for any set of $y$ boundary conditions.