Localization commutes with Hom for finitely-generated modules

The problem with your argument is quite subtle: you can't say $\pi f(m/1)\in N$, because the canonical homomorphism $i:N\to S^{-1}N$ may not be injective (because elements of $S$ might annihilate elements of $N$). That is, there is always some element $n\in N$ such that $i(n)=\pi f(m/1)$, but that $n$ might not be unique, and it is not clear that you can choose such an $n$ for each $m$ such that the map $M\to N$ you obtain is a homomorphism. This problem does not occur if $S$ acts on $N$ by non-zero divisors (i.e., $sn=0$ implies $n=0$ for $s\in S$, $n\in N$), because then $i$ is injective.

In general, in fact, there might not be any way to choose an $n$ for every $m$ such that you get a homomorphism. For instance, let $R=k[x,y_1,y_2,y_3,\dots]$ be a polynomial ring in infinitely many variables, let $M=R/(y_1,y_2,y_3,\dots)$, let $N=R/(xy_1,x^2y_2,x^3y_3,\dots)$, and let $S=\{1,x,x^2,\dots\}$. Then it is not too hard to see that there are no nonzero homomorphisms $M\to N$ (for an element of $N$ to be annihilated by every $y_n$, it would need to be infinitely divisible by $x$). But $S^{-1}M$ and $S^{-1}N$ are actually canonically isomorphic: both can be identified with $k[x,x^{-1}]$ with every $y_n$ acting trivially. In particular, this means $\operatorname{Hom}_{S^{-1}R}(S^{-1}M,S^{-1}N)$ is nonzero (it contains an isomorphism), whereas $S^{-1}\operatorname{Hom}_R(M,N)=S^{-1}0=0$. It is a good exercise to run through your proof with this example and see exactly how it breaks down.

To make the proof work in general, you need $M$ to be finitely presented, not just finitely generated. The idea behind the proof is then to choose an $n_i\in N$ lifting $\pi f(m_i/1)$ for each generator $m_i$ of $M$, where you choose $\pi\in S$ not just such that such a lift exists but also such that these $n_i$ will satisfy all of the finitely many relations between the $m_i$. This implies that the map $m_i\mapsto n_i$ extends to a well-defined homomorphism $M\to N$.