I am struggling with the proof of the commutativity of direct sums and tensor products of modules the professor gave us. Let $A$ be a ring, $M_i, N, P$ be $A$-modules, it goes as follows: he points out this isomorphism $$ Hom_A((\oplus_{i}M_i)\otimes N, P) \cong Hom_A(\oplus_i M_i, Hom_A(N,P)) \cong \prod_i Hom_A(M_i, Hom_A(N,P)) \cong \prod_i Hom_A(M_i \otimes N, P) \cong Hom_A(\oplus_i (M_i \otimes N), P)$$
Then he says: taking first $P = (\oplus_i M_i) \otimes N$ and then $P = \oplus_i (M_i \otimes N)$ and considering the maps $\alpha, \beta$ respectively corresponding to the identity map of $(\oplus_i M_i) \otimes N$ and $\oplus_i (M_i \otimes N)$ we get the desired isomorphism. Sincerely I don't understand this last part, why the images of the identity maps should give me the isomorphism? A different proof I elaborated is the following: to say that $M$ is the direct sum of the $M_i$ means there exist maps $\varphi_i: M_i \rightarrow M$ such that $$0 \rightarrow Hom_A(M,N) \rightarrow \prod_i Hom_A(M_i,N) \rightarrow 0$$ is exact for all $A$-modules $N$, where the map is: $$\psi \mapsto \{ \psi \circ \varphi_i \}$$ Set $\varphi_i : M_i \otimes N \rightarrow (\oplus_i M_i) \otimes N$ as $\varphi_i = k_i \otimes id_N$ where $k_i : M_i \hookrightarrow \oplus_i M_i$. Then as previously observed: $$ Hom_A((\oplus_{i}M_i)\otimes N, P) \cong Hom_A(\oplus_i M_i, Hom_A(N,P)) \cong \prod_i Hom_A(M_i, Hom_A(N,P)) \cong \prod_i Hom_A(M_i \otimes N, P)$$ and the map is exactly the one we need for the universal property of direct sum.
I would be grateful if you can tell me whether my proof is right or wrong and if you are able to explain me what I'm missing from the proof the professor gave us. Thank you!
Your proof looks fine.
For the part you were stuck on in the original proof, this is a typical application of Yoneda's lemma. In great generality, it says that the following two notions are equivalent:
The equivalence is easy to give explicitly. Given $f$ you can always define an associated $\theta$ by
$$ \theta_Z(g) = g \circ f $$
Conversely, from such a natural transformation, you can recover $f$ by plugging in a suitable choice of $g$ and $Z$, namely
$$ \theta_Y(1_Y) = 1_Y \circ f = f $$
Proving the theorem is just checking that going back and forth between the two notions are inverses, which is a relatively straightforward calculation. The hard part of the theorem is having the right definition of "natural transformation" and simply knowing what to prove!