While looking for the answer on the internet I came across an answer giving this explanation "Another way of seeing clearly why an exponential's argument should be dimensionless is to Taylor expand: $\exp(x)=1+x+x^2/2+\cdots$ Every term has a different dimension if x is dimensionful, and hence cannot be summed."
But this is not a proof in the sense we do in mathematics! So can anyone provide with a mathematically sound proof?
No proof is needed, it's true simply by definition of units. When dealing with units in any physics calculation, we generally respect the following unofficial axioms that define units:
1) A unit is treated as a variable in any calculation
2) Any number that is linear in a specific unit (with no intercept) is said to be a quantity of "those units".
So if "m" is a unit, that means that we can only classify a quantity as having "units of m" if it is of the form $k \text{m}$ for some unitless number $k$. Respecting the definition above, we see that $x = e^{2 \text{m}} = 1 + 2 \text{m} + 2 \text{m}^2 + \frac{4}{3} \text{m}^3 + \cdots$ is not strictly of form $k \text{m}$, thus by the definition above, it can't be said to have "units of m".
Aside from that definition, I don't think "units" has a formal definition in pure mathematics (perhaps someone will point me out wrong here), so without that formal definition, you can't make a proof. You need a definition like the one I wrote above.