The script doesn't run exactly as if you typed in the commands yourself... When it's done, it's returning you to where you were. You can check this by sticking a new line in the script before and after the cd...
This will print out the current directory the script is in. You will see that it starts in your current directory, then moves to root.