The first formula is when we are given the period interest rate (for example, the interest every three months). The second formula is where the yearly interest rate is given (so for example, the 3 month interest rate is the yearly interest rate divided by 4 because there are 4 periods of 3 months in a year.)
However it is dangerous to simply learn formula. It is more important to understand what is happening. Have you watched my lectures on this?