The expression $ax^2+15x+4+3x+5$ simplifies to $ax^2+18x+9$. Since it's the square of a binomial, it must equal $(cx+d)^2$ for some constants $c$ and $d$. Now $(cx+d)^2= c^2x^2+2cdx+d^2$ and we can equate its coefficients to that of $ax^2+18x+9$ like so:
\begin{eqnarray*}
a &=& c^2 \\
2cd &=& 18 \\
d^2 &=& 9
\end{eqnarray*}
We solve this system of 3 equations in 3 unknowns $a$, $c$, and $d$. Note that there are two solutions but both solutions have the same value of $a$.