I understand that the finite products in R-mod are the direct product of modules. But I am not sure how universal property is satisfied by the direct products? Can someone please explain.
Also, I see that finite products are same as coproducts in R-mod. Why is it so?
I will just demonstrate this for the binary case, as all other finite cases work essentially the same way. Suppose $M$ and $N$ are $R$-modules, then the direct product is just given by the Cartesian product $M\times N$ of their underlying sets equipped with pointwise addition and scalar multiplication. In particular, the uniqueness part of the universal property of the product is going to be guaranteed by the fact that module homomorphisms are structure-preserving functions of the underlying sets.
Therefore, we would only need to check the existence part. Suppose $Z$ is some $R$-module with homomorphisms $f:Z\to M$ and $g:Z\to N$. As I mentioned above, these are special functions of the underlying sets, so they induce a unique function $(f,g):Z\to M\times N$ given by mapping $z\mapsto (f(z),g(z))$. It just amounts now to checking that $(f,g)$ is a module homomorphism, which essentially just follows from how the module structure on $M\times N$ is defined. Therefore, the direct product of $R$-modules forms the categorical product in $R\mathbf{Mod}$.
As for why $M\times N$ also serves as the coproduct (in the finite case), the first thing to do is come up with inclusion maps $\iota_M:M\to M\times N$ and $\iota_N:N\to M\times N$. The natural choice is to define $\iota_M(m) := (m,0)$ and similarly $\iota_N(n) := (0,n)$. By the way $M\times N$ is an $R$-module, these will be $R$-module homomorphisms.
From here, there are two ways to go. If you know that the coproduct in $R\mathbf{Mod}$ is given by the direct sum, then it would be enough to observe that these inclusions realise $M$ and $N$ as submodules of $M\times N$ that are disjoint but span the entire module, hence giving that $M\times N\cong M\oplus N$.
Alternatively, you can just check that $M\times N$ with these inclusions will satisfy the universal property of the coproduct. If $Z$ is an $R$-module with functions $f:M\to Z$ and $g:N\to Z$, then the desired induced map $h:M\times N\to Z$ is given by $h(m,n) := f(m) + g(n)$. You can check that this is unique (by noting that $(m,n) = (m,0) + (0,n)$) and a module homomorphism. However, you might also notice that this is essentially the same reasoning as showing $M\times N\cong M\oplus N$.
It may be worthwhile to note that this breaks down in the infinite setting because an element of an arbitrary direct product may not necessarily admit a decomposition into a (necessarily finite!) sum of components, so in general the obvious map from the direct sum into the direct product will not be surjective.
As @rschwieb's comment mentions, the coincidence of the finite product and coproduct is a general phenomenon that occurs in any (pre)additive category. An argument for this is provided here (note that the only difference between being pre-additive and additive is the latter is assumed to actually have finite co/products).