Why do we require quotient to be surjective?

The quotient space has a universal property, namely if $f:X\rightarrow Z$ is a continuous function with the property that $(p(a)=p(b))\Rightarrow (f(a)=f(b))$, then $f$ factors through the quotient space. In other words, there exists a unique continuous function $\widetilde{f}:Y\rightarrow Z$ so that $f=\widetilde{f}\circ p$.

$$ \begin{matrix} X && \\ {\scriptsize p} \downarrow & \ \searrow^{f} & \\ Y & \underset{\bar f}{\longrightarrow} & Z \end{matrix} $$ If you don't take the quotient map to be surjective, this property fails (the map fails to be unique).

From the definition you state, it seems that one could define a quotient even if map $p$ is not surjective, but this breaks a desired property (that might not have been mentioned in your studies yet).

If you consider a "quotient map" $q$ that has all the properties above, but isn't surjective, then you can write $q$ as a composition of a (true) quotient and an inclusion map. In other words, the composition $X\stackrel{p}{\rightarrow} Y\stackrel{i}{\hookrightarrow}Z$ equals $q$.

$$ \begin{matrix} X && \\ {\scriptsize p} \downarrow & \ \searrow^q & \\ Y & \underset{i}{\hookrightarrow} & Z \end{matrix} $$