How do we prove intuitionistically that free modules of finite rank are projective?
So to answer my question, the proof is valid since:
As Rob Arthan pointed out, we can extract the elements $a_1,\ldots,a_n$ from a proof of surjectivity of $g$ (which, intuitionistically, explicitly describes how to find at least one preimage for each element of $B$).
As rschwieb remarked, since we only make finitely many choices there's no need of any strong choice principle.
It might be helpful to reframe the theorem more generally.
Let $\mathcal{S}$ be a regular category, and let $\mathcal{T}$ be the category of models of a finitary algebraic theory. Let $F\dashv G:\mathcal{T}\to\mathcal{S}$ be the free-forgetful adjunction ($G$ preserves covers because $S$ is regular). Then $FS$ is projective in $\mathcal{T}$ whenever $S$ is projective in $\mathcal{S}$.
For given cover $g:A\to B$ and morphism $f:FS \to B$, consider the diagram with the adjunct $f' : S\to GB$ and $Gg : GA \to GB $. Then $Gg$ is a cover, so from $S$ being projective we get a map $h :S \to GA $ that "completes the triangle". Taking adjuncts again gets us $f=gh'$ for some $h' :FS \to A$.
Then the additional ingredient needed is that finite sets are projective. That's a theorem once you've chosen the correct notion of "finite set".