How many distinct ways can the number be written as product of $3$ factors? How many distinct ways can the number $126$ be written as a product of $3$ positive integer  factors?
I found that the prime factors are $126=2\times3\times3\times7$. But how to get number of different ways out of this?
We're trying to count factorizations $126=abc$ with $a\le b\le c$.  Note that, except for $1\cdot1\cdot126$ and $3\cdot3\cdot14$, the rest have $a\lt b\lt c$, since $3$ is the only repeated prime factor of $126$.  Let $m$ denote the number with $a\lt b\lt c$, so the number we want to find is $m+2$.

If we remove the condition $a\le b\le c$, the number of factorizations $126=abc$ is $6m+3\cdot2=6m+6$.  But it's also $3\cdot6\cdot3=54$, since the $2$ and $7$ can be assigned to any of the three factors and the pair of $3$'s can be assigned in $6$ different ways.  Setting $6m+6=54$, we find $m=8$, so the answer we're after is $8+2=10$.
As you said, prime factors of 126 are 126=2*3*3*7

Then in order to make it as a product of 3 positive integer factors, you need to pick two out of four from these prime numbers and multiply them to get an integer, leaving the other two as prime. But since number 3 repeat twice, you need to divide by 2!

So there are $\frac{4C2}{2!} = 3$ ways