We want to show that,

f(n)=g(n) for any positive integer n.

Your statement is not actually true . It is true if n>1.

You need an addition fact that f(1)=g(1).

But anyway, let me show that they agree on n>1.

If n>1 we can prime factorize,

n=p_1^(a_1) * p_2^(a_2) * ... * p_k^(a_k)

Now,

f(n)=f(p_1^(a_1)*p_2^(a_2)*...*p_k^(a_k))=f(p_1^(a _1))*...*f(p_k^(a_k)).

Because,

gcd(p_i,p_j)=1 if i!=j.

The same thing for g(n).

But,

f(p_i^(a_i))=g(p_i^(a_i))

Thus,

f(n)=g(n) for n>1.