The definition of $a^x$ can be done in steps.
For $x$ a nonnegative integer and $a\neq 0$, we define $a^x$ inductively: $a^0 = 1$, and $a^{n+1} = a^n\times a$. By mathematical induction this defines $a^m$ for all nonnegative integers $m$.
It is then a further exercise in induction to prove that $a^na^m = a^{n+m}$, $(ab)^n = a^nb^n$, and $(a^n)^m = a^{nm}$. For instance, fixing $n$, we prove that $a^na^0 = a^{n+0}$ (true, since $a^0=1$ by definition); assuming that $a^na^m = a^{n+m}$, then
$$a^n(a^{m+1}) = a^n(a^ma) = (a^na^m)a = a^{n+m}a = a^{(n+m)+1} = a^{n+(m+1)}.$$
We can also define $0^n$ for any positive $n$ by letting $0^1 = 0$, $0^{n+1} = 0^n0$.
Having defined $a^n$ for all nonzero real numbers $a$ and all nonnegative integers $n$, we extend the definition to negative integers as follows: if $m$ is a negative integer, $m=-n$ with $n$ a positive integer, then we define
$$a^m = a^{-n} = \frac{1}{a^n}.$$
It is now easy to check that $a^na^m = a^{n+m}$ still holds for any integers $n$ and $m$, that $(ab)^n = a^nb^n$, and that $(a^n)^m = a^{nm}$. We deal with the case of negative integer exponents by using the definition. For example, to show $a^{n+m}=a^na^m$, we note that if $n,m\geq 0$, then we have already proven it. If $n\gt 0$, $m\lt 0$, and $n+m\geq 0$, then
$$a^{-m}a^{n+m} = a^{n+m-m} = a^n$$
by the positive case, and multiplying both sides by $\frac{1}{a^{-m}} = a^m$ gives the equality. Similar arguments hold if $n+m\lt 0$. If both $n$ and $m$ are negative, then taking reciprocals reduces to the positive case.
Having defined $a^n$ for all $a\neq 0$ and all integers $n$, we extend the definition to rational numbers. In order to do that, we need to use some facts about the real numbers, and we need to restrict our choice of $a$: we can only do the following if $a\gt 0$.
Given a positive integer $q$, $a^{1/q}$ is defined to be the unique real number $r$ such that $r^q = a$. Such a number exists by the Intermediate Value Theorem (consider the function $f(x) = x^q$) and is unique (the function $f(x)=x^q$ is strictly increasing on $[0,\infty)$).
Then given a rational number $p/q$ with $p$ and $q$ relatively prime, $q\gt 0$, we define $a^{p/q} = (a^{p})^{1/q}$. If $n$ and $m$ are arbitrary integers, we define $a^{n/m}$ to be $a^{p/q}$, where $\frac{n}{m}=\frac{p}{q}$ and $p$ and $q$ are relatively prime, and $q\gt 0$.
This definition restricts to the previous definition when $q=1$: by definition, $a^{p/1}= (a^p)^1$ is the unique real number $r$ such that $r^1 = a^p$; that is, $a^{p/1} = a^p$.
Then one shows that this definition still satisfies the exponentiation rules: $a^{p/q}a^{r/s} = a^{(p/q)+(r/s)}$, $(ab)^{p/q} = a^{p/q}b^{p/q}$, and $(a^{p/q})^{r/s} = a^{pr/qs}$.
For example, to show that $a^{(p/q)+(r/s)} = a^{p/q}a^{r/s}$, it suffices to show that $a^{p/q}a^{r/s}$ is the unique real number which, when raised to the $qs$th power, gives $a^{ps+qr}$, since $\frac{p}{q}+\frac{r}{s} = \frac{ps+qr}{qs}$. But this is merely an assertion about integer powers, so we can use the already established properties:
$$(a^{p/q}a^{r/s})^{qs} = (a^{p/q})^{qs} (a^{r/s})^{qs} = ( ( a^{p/q})^q)^s( ( a^{r/s})^s)^q.$$
Now, $a^{p/q} = b$ means that $b^q = a^p$. So
$$ ((a^{p/q})^q)^s = (a^p)^s = a^{ps}.$$
Similarly, $((a^{r/s})^s)^q = a^{rq}$. So
$$(a^{p/q}a^{r/s})^{qs} = a^{ps}a^{rq} = a^{ps+rq},$$
which proves that $a^{p/q}a^{r/s} = a^{(ps+rq)/qs} = a^{(p/q) + (r/s)}$.
Etc.
Having defined exponentiation for rational exponents, we extend it to exponentiation for any real number in one of several ways:
One way is as follows: Given a real number $r$, let $q_n$ be an increasing sequence of rational numbers such that $q_n\to r$. Then we define $a^r = \lim\limits_{n\to\infty}a^{q_n}$.
One needs to show that this is well-defined (the limits exists, and if $p_n$ is a different sequence of rationals converging to $r$, then the limit of $a^{p_n}$ equals the limit of $a^{q_n}$). This can be done; if you do that, then the fact that $(a^r)^s = a^{rs}$ follows by showing that if $p_n\to r$ and $q_m\to s$, then showing that
$$
\lim_{m\to\infty}\lim_{n\to\infty}(a^{p_n})^{q_m} = \lim_{m\to\infty}\lim_{n\to\infty}a^{p_nq_m}$$
will converge to the same thing as $a^{p_nq_n}$, and therefore to $a^{rs}$.
Alternatively, one can define $a^r$ is the supremum of $a^{p/q}$ with $p/q$ rational numbers smaller than $r$. There is no issue of well-definedness here ($a^r$ exists and is unique), and then one just needs to show that we can express rationals smaller than $rs$ in terms of rationals smaller than $r$ and rationals smaller than $s$, and then use the properties of the exponentiation that we already know for rationals.
An entirely different approach is to define the exponential function $e^x$ using a Taylor Series:
$$e^a = \lim_{n\to\infty}\left(1 + \sum_{k=1}^n\frac{a^k}{k!}\right),$$
then showing that this has the "usual" properties, defining the logarithm as its inverse, and finally defining $a^b = e^{b\ln a}$. Then the rule $(a^b)^c = a^{bc}$ follows directly from the properties of the logarithm.