Normally I expect bash to execute commands in order when separated by a semicolon
eg, cmd1 executes before cmd2 in:
echo 'my password' | sudo -S su -c "echo a 1>&2 ; $(echo b 1>&2)" root
$ echo "hello $(echo world)" hello world
$( ... ) runs the command inside and substitutes the collected output, i.e. the command above ends up running
echo "hello world".
sudo -S su -c "echo a 1>&2 ; $(echo b)"
would end up running
sudo -S su -c "echo a 1>&2 ; b"
$(echo b 1>&2) the command writes
b to stderr (and nothing to stdout), so while the shell is processing the string you see
b appearing on the screen, and then the whole
$( ... ) construct is replaced by nothing (because it writes nothing to stdout).
What ends up running is
sudo -S su -c "echo a 1>&2 ; " root
If all you want to do is run a command in a subshell, that's
( ... ), not
$( ... ).