Are these two equations: $$ \ (g^a Mod\ p)^b\, $$
$$ \ (g^a)^b (Mod\ p)\, $$ one and the same? If yes then how And if no then how to solve the first equation?
Your question is addressed by a repeated application of the following easily proved fact:
If $a\equiv a'\pmod n$ and $b\equiv b'\pmod n$, then $ab\equiv a'b'\pmod n\,$.