Unexpected behavior of bash script used to sync dotfiles

If target is an already existing directory, then the command ln -s source target will create a link target/source in that directory, pointing to the original source. That's what's going on here: the directory .emacs.d/snippets/ exists at the start, and you're running the command

ln ~/.dotfiles/.emacs.d/snippets ~/.emacs.d/snippets

which creates a link in the existing snippets to the other snippets.

You could do ln -s ~/.dotfiles/.emacs.d/snippets/* ~/.emacs.d/snippets instead. Or delete everything in .emacs.d and do ln -s ~/.dotfiles/.emacs.d/* ~/.emacs.d. (Obviously make copies first in case something goes wrong.) Or perhaps even delete .emacs.d and create a new version which is just a symlink.