Let $R$ be a commutative ring, and let $A$ and $B$ be right $R$-modules. Suppose that the following two sequences are exact: $$ R^u\stackrel{Q}{\to} R^s\stackrel{\pi}{\to}A\to 0 \\ R^r\stackrel{f}{\to} A\to B\to 0 $$ and there exists a map $P:R^r\to R^s$ such that $\pi\circ P=f$. Also $P$ and $Q$ can be considered to be matrices of appropriate dimensions (and are multiplied on the right. That they are right-modules and matrix multiplication is on the right is not super important to the problem, but I'm too tired to convert it to left)
(Sorry, I don't know how to draw commutative diagrams here, but I've included a picture of the commutative diagram.)
Question: What is a presentation matrix for $B$?
Secondary Question: Is there a way to get a formula for $f$?
Known: $A=R^s/R^uQ$, that is $Q$ is a presentation matrix for $A$, and $B=A/f(R^r)=A/\pi(R^rP)$. Combining these two facts, we obtain $$B=\dfrac{R^s/R^uQ}{\pi(R^rP)}$$
My suspicion is that $B$ is presented by the block matrix $$V=\begin{pmatrix} P\\ Q \end{pmatrix} $$ and $R^r\oplus R^u\stackrel{V}{\to}R^s\to B\to 0$ is exact. My reasoning is, $B=A/f(R^r)$ and $f=\pi\circ P$. $A$ has $s$ generators and $u$ relations with presentation matrix $Q$. So $B$ has at most $s$ generators. Given $x\in R^r$, $xP$ gives $f(x)$ in terms of the generators of $A$. So $R^rP$ gives $r$ relations for $B$. But these aren't enough, they can be further simplified with the relations $R^uQ$. So $B=R^s/(R^rP)/(R^uQ)=R^s/(R^{r+u}V)$. I don't know if this makes any sense. I'm feeling very stupid right now. Any help would be much appreciated.
$\require{AMScd}\DeclareMathOperator{\cok}{cok}\newcommand{\psm}[2]{\left[\genfrac{}{}{0pt}{}{#1}{#2}\right]}$Your suspicion is correct, that's $V$ is the representation matrix of $B$. This means that $\pi g:R^s\to B$ (with diagrammatic order composition) is the cokernel of $V$. To prove this, consider the following commutative diagram with exact rows \begin{CD} R^u@>Q>>R^s@>\pi>>A@>>>\{0\}\\ @.@APAA@|\\ @.R^r@>>f>A@>>g>B@>>>\{0\} \end{CD} Then $\pi$ is the cokernel of $Q$ and $g$ is the cokernel of $f$. Note that the cokernel of $V$ is the cointersection of cokernels of $P$ and $Q$, that's the diagonal of the right-handed square in the following commutative diagram (where both squares are pushout): \begin{CD} R^r@>P>>R^s@>\pi>>A\\ @VVV@VV\cok PV@VVgV\\ \{0\}@>>>\bullet@>>>B \end{CD} hence the assertion follows.
If you don't know this property of cokernels argue as follows. Clearly, we have $$\psm PQ\pi g=\psm{P\pi g}{Q\pi g}=\psm{fg}{Q\pi g}=0$$ for $fg=0$ because $g$ is the cokernel of $f$ (by exactness of bottom row) and $Q\pi=0$ by exactness of upper row. On the other hand let $k:R^s\to Y$ such that $$\psm PQk=0$$ that's $Pk=0$ and $Qk=0$. From $Pk=0$ we get $k=(\cok P)u$ where $\cok P$ denote the cokernel of $P$, for some $u$ and $k=\pi v$ for some $v$, because $\pi$ is the cokernel of $Q$. Since $(\cok P)u=k=\pi v$, by universal property of pushout, there exists one and only one morphism $h:B\to Y$ such that $v=gh$, hence $k=\pi gh$.