What is a basis of P2?

I think you need to be clear about what you mean by "representing" the polynomial. You can if you like make the assignments

$$ x^2 \;\; \to \;\; \left [ \begin{array}{c} 0\\ 0\\ 1\\ \end{array} \right ] \hspace{2pc} x \;\; \to \;\; \left [ \begin{array}{c} 0\\ 1\\ 0\\ \end{array} \right ] \hspace{2pc} 1 \;\; \to \;\; \left [ \begin{array}{c} 1\\ 0\\ 0\\ \end{array} \right ] $$

Then your polynomial can be represented by the vector

$$ ax^2 + bx + c \;\; \to\;\; \left [ \begin{array}{c} c\\ b\\ a\\ \end{array} \right ]. $$

To describe a linear transformation in terms of matrices it might be worth it to start with a mapping $T:P_2 \to P_2$ first and then find the matrix representation.

Edit: To answer the question you posted, I would take each basis vector listed above and apply the matrix to it:

\begin{eqnarray*} \left [ \begin{array}{ccc} 3 & 2 & 7 \\ 0 & 1 & 0 \\ 4 & 0 & 1 \\ \end{array} \right ] \left [ \begin{array}{c} 1 \\ 0\\ 0\\ \end{array} \right ] & = & \left [ \begin{array}{c} 3 \\ 0 \\ 4 \\ \end{array} \right ] \;\; \to \;\; 4x^2 + 3 \\ \left [ \begin{array}{ccc} 3 & 2 & 7 \\ 0 & 1 & 0 \\ 4 & 0 & 1 \\ \end{array} \right ] \left [ \begin{array}{c} 0 \\ 1\\ 0\\ \end{array} \right ] & = & \left [ \begin{array}{c} 2 \\ 1\\ 0\\ \end{array} \right ] \;\; \to \;\; x+ 2 \\ \left [ \begin{array}{ccc} 3 & 2 & 7 \\ 0 & 1 & 0 \\ 4 & 0 & 1 \\ \end{array} \right ] \left [ \begin{array}{c} 0 \\ 0\\ 1\\ \end{array} \right ] & = & \left [ \begin{array}{c} 7 \\ 0\\ 1\\ \end{array} \right ] \;\; \to \;\; x^2 + 7. \end{eqnarray*}