Find basis so Transformation Matrix will be diagonal $e_1,e_2$ will be basis for $V$. $W$ has a basis $\{e_1+ ae_2,2e_1+be_2\}$. Choose an $a,b$ s.t. that the basis for $W$ will have a transformation matrix $T$ will be in diagonal form.
$T(e_1) = 1e_1+5e_2$
$T(e_2) = 2e_1+4e_2$
$V$ and $W$ are linear spaces of dimension $2$.

you want to find $a, b$ so that $$T(e_1+ae_2) = k_1(e_1+ae_2), 
T(2e_1 + be_2) = k_2(2e_1 + be_2) \text{ for some } k_1, k_2. \tag 1  $$
we are given $$Te_1 = e_1 + 5e_2, Te_2 = 2e_1 + 4e_2. \tag 2 $$ subbing $(2)$ in $(1)$ and equating the coefficients, we get $$ 1 + 2a = k_1, 5 + 4a = k_1a, 2+2b = 2k_2, 10 + 4b = k_2b \tag 3 $$
that is $$5+4a = a(1+2a)=a + 2a^2\to 2a^2-3a - 5 = 0 \to 
a = -1, 5/2.$$  and $$10 + 4b = b(1+b) \to b^2 - 3b -10 = 0\to b = -2, 5. $$
