For a positive integer $N$, let $mathscr{C}_N(mathbb{Q})$ be the rational cuspidal subgroup of $J_0(N)$ and $mathscr{C}(N)$ be the rational cuspidal divisor class group of $X_0(N)$, which are both subgroups of the rational torsion subgroup of $J_0(N)$. We prove that two groups $mathscr{C}_N(mathbb{Q})$ and $mathscr{C}(N)$ are equal when $N=p^2M$ for any prime $p$ and any squarefree integer $M$. To achieve this we show that all modular units on $X_0(N)$ can be written as products of certain functions $F_{m, h}$, which are constructed from generalized Dedekind eta functions. Also, we determine the necessary and sufficient conditions for such products to be modular units on $X_0(N)$ under a mild assumption.