escapeshellarg() adds single quotes around a string and quotes/escapes any existing single quotes allowing you to pass a string directly to a shell function and having it be treated as a single safe argument.
escapeshellarg, as its name indicates, is used as passing shell argument(s). For example, you want to list current directory,
$dir = "."; system('ls '.escapeshellarg($dir)); escapeshellcmd('ls $dir');
Both do similar things and simply depends on how you handle your logic, do make sure your normalize and validate your input before passing directly to these methods for better security.