Note that you actually only stumbled upon two different meanings for the same notation.
Firstly, $f^{(n)}$ is standard notation for the $n$-th derivative. Anyone in a calculus or analysis context with some familiarity of the field will understand it. The brackets make it a different notation from $f^{n}$, so it's not a new meaning for the same notation.
Now the notation $f^n$ usually refers to repeated application of a function. In this context, function composition $\circ$ is viewed as an operation just like $\cdot$ or $+$, and the notation for repeatedly doing it is copied from multiplication. Also note that the notation $f^{-1}$ extends this in exactly the same way as it does for multiplication. $2^{-n}$ is the number which, if multiplied by $2^n$, gives the multiplicative identity $1$. The function $f^{-n}$ is the function which, if composed with $f^n$, gives the identity function.
However, in some calculus or analysis contexts, it can also mean normal exponentiation. For instance, it is rare to have a useful application for a function like $\sin(\sin(x))$, but there are useful contexts for products of sines, so in context everyone understands that $\sin^2$ is $\sin\cdot\sin$, not $\sin\circ\sin$.
With time you will get a better feeling for when each meaning applies. But usually it is clear from context - unless you are not yet familiar enough with the field, or the author communicates badly.