fft() produces output that is positive frequencies followed by negative frequencies. It is common to want to plot negative frequencies followed by positive frequencies. fftshift() re-arranges fft output to exchange negative and positive frequencies.
If you have fft output that has already been rearranged to negative and positive frequencies, you might want to fftshift() it back to positive then negative before doing ifft .
Your product of rect() functions is not fft output and probably should not be fftshift() .
Yes, you can in theory apply fftshift() to time domain data, but the implication would be that the data had previously been deranged in time. Your rect .* rect has not be deranged in time.
I think your ft2() should probably be something like
G = fftshift(fftshift(ff2(g),1),2) * delta^2;

