We have that $a^n$ for some natural number $n$ is equal to
$$
\underbrace{a\cdot a \cdots a}_{n\text{ times}}
$$
just as you said. This exponentiation operation fulfills a few relations, which I'm sure you've seen, such as $a^n\cdot a^m = a^{n+m}$, $(a^n)^m = a^{nm}$ and $a^n:a^m = a^{n-m}$ (but only for $n>m$ at the moment). As long as $n$ and $m$ are positive, this can be checked easily.
Say want to figure out what the best possible definition of $a^n$ is for negative integers $n$. Or $a^0$. What do we want from such a definition? Well, we want the same relations as above to apply. This, in specific, means that we want $1 = a^n:a^n = a^{n-n} = a^0$. The same rules also force $a^n\cdot a^{-n} = a^0 = 1$, which in turn implies $a^{-n} = \frac1{a^n}$. This paragraph, of course, requires that $a \neq 0$.
Now that we have defined $a^n$ for all integers, what about fractions? What would we want from a number such as $a^{1/n}$? Well, one thing we might want to demand is that $(a^{1/n})^n = a^{n/n} = a$. As long as $a> 0$, the equation $x^n = a$ has the single positive solution $x = \sqrt[n]{a}$, by definition of $n$-th root. Therefore, for the rule $(a^n)^m = a^{nm}$ to hold for rational powers $n, m$ and positive $a$, we must have $a^{1/n} = \sqrt[n]a$.
At this point, we must of course check that the definitions we have so far actually still fulfill the three rules I set up in the beginning. In every case, one of the rules forced a choice for a definition, but it could be that as we expanded the possible domain of $n$, the rules came at odds. It turns out they don't, but it has to be checked.
Now, for irrational exponents, there is no direct, satisfying definition that comes from expanding what we already have. We just require that the function $x \mapsto a^x$, which is previously defined for $x$ rational, is continuous for all real $x$. This forces a specific function value for any real number, and it turns out that the exponentiation rules still hold, so it's a good definition.
The alternative definition that people might use for real exponents is that
$
a^x = \operatorname{Exp}(x\ln a)
$where $$\operatorname{Exp}(x) = 1+x+\frac{x^2}2 +\frac{x^3}6 + \cdots + \frac{x^n}{n!} +\cdots$$
and $\ln a$ can be defined, for instance, by $\int_1^a \frac 1t dt$. This is a full definition that tells you exactly what $a^x$ is, but it doesn't pop nicely out of the original $a^n$-definition.