I assume discrete time. Suppose I start with some amount of money $P_{0}$. Then, using a simple rate of interest $r$ for a given period of time, I would have
$$P_{t}= P_{0} (1+r)^{t}$$
Suppose $t$ represents years. Now, suppose I want the payments to happen more frequently, say $n$ times a year, but I want $t$ to still represent years. Then I can model the amount I get paid as
$$P_{t}= P_{0} (1+r)^{nt}$$
This model can't be right however because, as one user pointed out, as $n\rightarrow \infty$, then $P_{t} \rightarrow \infty$. We want \begin{align*} t\rightarrow \infty &\Rightarrow P_{t} \rightarrow \infty\\ n\rightarrow \infty &\Rightarrow P_{t} \text{ converges to some limit} \end{align*} Ok, so we need a way to make it such that the limit exists as $n\rightarrow \infty$ and that necessitates adding a term $f(n)$ such that
$$P_{t}= P_{0} \left(1+\frac{r}{f(n)}\right)^{nt}$$
Why does compound interest typically involve a $f(n)=n$? I know the reason why we need $f(n)$ to have certain properties like $f(n)=n$ is because the purpose of this is to reduce the interest rate to prevent the infinity stated earlier. But I don't get why that needs to take the form of $f(n)=n$ specifically as opposed to some general class of functions $f(n)$, where they could have certain restrictions to give the derivatives properties similar to the usual formula.
I also recognize that by choosing to use $f(n)=n$, then in the limit, we have the continuous case of $P_t = P_0 \cdot e^{rt}$. But that doesn't change the fact there could be many compound interest formulas for the discrete case, even if most can't be made into a continuous version.
Is the choice of $f(n)=n$ just by convention or is there a reason for this choice?