The rule is when you take a power to a power you multiply the exponents:
Yours was a special case. Not only did you want to take the base to a power, you also wanted to take the power to a power.
In this case you must work from the top down. If you were putting this in a calculator you would have to enter it this way:
2^(3^2) = 512
The parentheses tell the calculator to perform this operation first to get 9, then take 2 to the 9th power to get 512.
If you entered it 2^3^2, you would get 64 because the calculator performs the operations from left to right: 2^3 is 8 and 8^2 is 64.
It's a little tricky when you stack exponents. Just remember to start at the top and work your way down.
Good luck.