Let's do a stack trace of your algorithm with say b = 2 and exp = 3
base = 2, exp = 3
ans = 2
ans = ans * base = 4
ctr = 1
exponent > 1 = True
ctr <= exponent = true
mypow(2, 3) =>
base = 2, expo = 3
ans = 2 <- Problem
ctr = 1 <- Problem
exponent > 1 = True
ctr <= exponent = true
mypow(2, 3) => ad infinium
The problem is you're defining a new value of ans and ctr each call. Thus they never change and the recursion goes forever. If you do want to do it this way(there's an easier way) then you would need to pass ans and ctr by reference into the functions and define them outside.
There is a simple fast exponential recursive algorithm but for a naive simple algorithm use the following logic:
a^1 = a
a^x = a*a^(x-1)
So exponent(a, x) = a*exponent(a, x-1)
If you want to use the fast algorithm(I won't go into detail as an exercise):
Base case is the same.
a^(x) = (a*a)^x/2 if x is even
a^(x) = a * (a*a)^(x-1)/2 if x is odd