Q:

Simplification of Modulo formula

I believe that this:
(5^3 mod 57)^5 mod 57

is the same as:
(5^3)^5 mod 57

But what is the logic of this simplification?

A:

Indeed it is, yes.
The logic is that taking modulo can be exchanged with multiplication, i.e. $$a \cdot b \mod{c} = (a \mod{c}) \cdot (b \mod{c}) \mod{c}$$ for all $a,b,c$.
This claim can be proven for example using Euclidean division. Then applying this result multiple times, one can show through induction that it also holds for powers.
edit due to the comment:
Let's first assume the identity above is true. Now to apply it to your problem, we use it multiple times:
What you want to show is that 
$$(5^3 \mod{57})^5 \mod{57} = (5^3)^5 \mod{57}.$$
For that, we first look at the left hand side:
$$(5^3 \mod{57})^5 \mod{57}$$ $$= \left[(5^3 \mod{57})\cdot (5^3 \mod{57})\cdot  (5^3 \mod{57})\cdot  (5^3 \mod{57})\cdot  (5^3 \mod{57})\right]\mod{57}$$
Now applying the above formula multiple times (reading it from right to left), we can draw this together to be
$$(5^3 \cdot 5^3 \cdot 5^3 \cdot 5^3 \cdot 5^3) \mod{57}$$
which is simply
$$(5^3)^5 \mod{57}.$$
Just in case, also some ideas on how to prove the identity:
Let $a,b,c$ be integers. Write $a = rc + (a\mod{c})$ for some $r$ and $b = sc + (b\mod{c})$ for some $s$. That such integers $r,s$ exist is basically the definition of modulo. Now we can compute 
$$a\cdot b = (rc + (a\mod{c})) (\cdot sc + (b\mod{c}))$$
$$ = rsc^2 + (a\mod{c})c + (b\mod{c})c + (a\mod{c})(b\mod{c}).$$
If we now look at it mod $c$, you will notice that all but the last term contain a $c$ as a factor, so they all cancel out mod $c$. What is left is then exactly the identity.

