sudo -s creates a login shell session. Then after you exit that it, you return to being a regular user. Then it executes the 4th line, but you aren't root at that point so it fails.
You can't simply stick a sudo in front of the echo statement since that's a built-in command.
So try this instead:
sudo sh -c "echo 3 > /proc/sys/vm/drop_caches"
From man sudo:
The -s (shell) option runs the shell specified by the SHELL
environment variable if it is set or the shell as specified in passwd(5).
If a command is specified, it is passed to the shell for execution.
Otherwise, an interactive shell is executed.