We all know that $x \cdot \mathrm{cm}$ is "$x$ times $\mathrm{cm}$" but I was wondering about what is $x^{\mathrm{cm}}$ ($x$ to the power $\mathrm{cm}$) can be define this $x^{\mathrm{cm}}$ thing? For example what is $2^{\mathrm{cm}}$? Do physics have an answer?
I just have a little thought about it. We can write this as $e^{\mathrm{cm} \ln x}$ and we have a Maclaurin series for $f(x)=e^x$ function so we can write like that. But if we write like that we will have $\mathrm{cm}^4$, $\mathrm{cm}^5$, $\mathrm{cm}^6$, $\ldots$? and I don't know what that units mean.
An expression like $e^{1 \text{ cm}}$ simply does not work: as you're noticing, there is no way to make sense of the units. What happens in the Taylor series expansion is an example of that: you'd get terms with $\text{cm}, \text{cm}^2, \text{cm}^3$ in them all added together, but it's invalid to add things with different units.
In expressions like $a^x$, or $\ln x$, the value of $x$ simply has to be unitless.
You occasionally see exponentials and logarithms in physics equations, but the result will always either be unitless or can be converted into a unitless quantity. For example, in the Wikipedia article on thermodynamic equations you see a lot of $\ln \frac{V_1}{V_2}$ or $\ln \frac{T_1}{T_2}$ where the units inside the logarithm (volume or temperature) cancel. Sometimes people carelessly write these as $\ln V_1 - \ln V_2$ or $\ln T_1 - \ln T_2$ instead, which is technically a difference of two meaningless expressions, but we can make sense of this if we combine the two logarithms.
For another example, in Newton's law of cooling we see a factor of $e^{-t/\tau}$ where $t$ and $\tau$ have units ($t$ is time and $\tau$ is a time constant) but $-t/\tau$ is unitless.