You need to add
-mindepth 1. Otherwise you
cd .. out from the original base directory in the first loop repetition and end up in its parent directory.
Easy to notice when you dry-run the
$ find . -type d -maxdepth 1
In the first loop, you
cd ., which does nothing, and then
cd .., from which you're unable to enter all the other directories you found.
If it's no problem with spaces in directory names, you can always
find $PWD instead of
find . to use absolute paths, or store the original
$PWD in a variable you can
cd to (
cd - likely won't work though), instead of