Normally a shell command only executes when the previous command finishes. When you execute ssh, that command does not finish until the ssh session finishes. Presumably you dropped into a remote shell. If you exit that shell it will return to the script and execute the next command. You could of course put & ampersand after a command so that the shell doesn't wait, though it doesn't seem to make much sense to run ssh in the background, unless you are running something remotely, and not just a shell.