I suspect you came to Mathematica after using a procedural programming language where you had little choice but to spell out in detail such iterations. In Mathematica, however, there are _much_ easier ways to construct to kind of list you want.

Another way that more directly exposes the iteration involved is by using Table:

Flatten[Table[a^b, {a, 2, 5}, {b, 2, 5}]]

WAlthough the numbers in your example are modest in size, and efficiency should not be at the top of your concerns as a Mathematica beginner, still it's illuminating to compare the efficiency of your original, explicitly iterative For loop as compared with the functional and Table approaches. For that, I changed the upper bound 5 to 1000.