Let me make Faiq Irfan's answer easier to understand using "proof by example".
We know that
$$e = \lim_{n\rightarrow\infty}\left(1+\frac 1n\right)^n$$
where $n$ goes to infinity as a real number (not as a natural number).
Let $m=2023n$, i.e., $n=\frac m{2023}$.
$$e = \lim_{\frac m{2023}\to\infty}\left(1+\frac 1{\frac m{2023}}\right)^{\frac m{2023}}$$
Since $\frac m{2023}\to\infty$ if and only $m\to\infty$ (thanks to $2023>0$), we have
$$e = \lim_{m\rightarrow\infty}\left(1+\frac 1{\frac m{2023}}\right)^{\frac m{2023}}$$
Now raising both side to the power of $2023$, we get
$$\begin{aligned}e^{2023}
&= \left(\lim_{m\rightarrow\infty}\left(1+\frac 1{\frac m{2023}}\right)^{\frac m{2023}}\right)^{2023}\\
&= \lim_{m\rightarrow\infty}\left(\left(1+\frac 1{\frac m{2023}}\right)^{\frac m{2023}}\right)^{2023}\\
&= \lim_{m\rightarrow\infty}\left(1+\frac {2023}{m}\right)^m
\end{aligned}$$
Well, there is nothing particular about $2023$ except that $2023>0$. Hence, we can replace $2023$ by any $x>0$.
$$e^{x} = \lim_{m\rightarrow\infty}\left(1+\frac {x}{m}\right)^m$$
In case the symbol $n$ is preferred, we can replace $m$ by $n$ to get
$$e^{x} = \lim_{n\rightarrow\infty}\left(1+\frac {x}{n}\right)^n$$
Once you have verified the proof above, you can see that instead of replacing $n$ by $\frac m{2023}$ in the first step, we can replace $n$ by $\frac n{x}$, where $n$ in $\frac nx$ means the $m$ in $\frac m{2023}$ and $x$ in $\frac nx$ means 2023 in $\frac m{2023}$, treating $x$ as a constant $>0$. We will recover Faiq Irfan's answer.
So the change of variable in Fraq Irfan's answer is pretty natural. It is just a linear change of one variable.
By the way, Faiq Irfan's answer misses the case when $x\le0$.
For the case when $x<0$, we can prove first
$$e^{-1} = \lim_{n\rightarrow\infty}\left(1-\frac 1n\right)^n$$
and then proceed similarly to the case above for $x>0$.
The case when $x=0$ is trivial.
In case you believe
$$e = \lim_{n\rightarrow\infty}\left(1+\frac 1n\right)^n$$
should be understood as
$$e = \lim_{n\rightarrow\infty,\ n\in \Bbb N}\left(1+\frac 1n\right)^n\tag{*}\label{*}$$
let me prove that $\eqref{*}$ implies
$$e = \lim_{n\rightarrow\infty,\ n\in \Bbb R}\left(1+\frac 1n\right)^n\tag{***}\label{***}$$
$$\begin{aligned}
\lim_{n\rightarrow\infty,\ n\in \Bbb R}\left(1+\frac 1n\right)^n
&\le\lim_{n\rightarrow\infty,\ n\in \Bbb R}\left(1+\frac 1{\lfloor n\rfloor}\right)^{\lceil n\rceil}\le\lim_{m\rightarrow\infty,\ m\in \Bbb N}\left(1+\frac 1m\right)^{m+1}\\
&=\lim_{m\rightarrow\infty,\ m\in \Bbb N}\left(1+\frac 1m\right)^m\lim_{m\rightarrow\infty,\ m\in \Bbb N}\left(1+\frac 1m\right)^1=e\cdot1=e\\
\lim_{n\rightarrow\infty,\ n\in \Bbb R}\left(1+\frac 1n\right)^n
&\ge\lim_{n\rightarrow\infty,\ n\in \Bbb R}\left(1+\frac 1{\lceil n\rceil}\right)^{\lfloor n\rfloor}\ge\lim_{m\rightarrow\infty,\ m\in \Bbb N}\left(1+\frac 1m\right)^{m-1}\\
&=\lim_{m\rightarrow\infty,\ m\in \Bbb N}\left(1+\frac 1m\right)^m\lim_{m\rightarrow\infty,\ m\in \Bbb N}\left(1+\frac 1m\right)^{-1}=e\cdot1=e
\end{aligned}$$
Hence,
$$\lim_{n\rightarrow\infty,\ n\in \Bbb R}\left(1+\frac 1n\right)^n=e$$.