I understand one of the direction, but not the following:
Why after defining $T$ as $T(a_1v_1 + ...+ a_nv_n) = a_1w_1 +...+ a_mw_m$, $T$ is surjective? How can I come up with such definition? What does it mean by right side of the equation make sense?

Take for example $m=2$, $n=3$. Then for $a_1v_1+a_2v_2+a_3v_3\in V$ we have the uniquely defined element $a_1w_1+a_2w_2\in W$. (Note that this would not work the other way around!) This map is surjective since for any $a_1w_1+a_2w_2\in W$, the element $a_1v_1+a_2v_2\in V$ maps to $a_1w_1+a_2w_2$.