It seems like a basic limitation of the variable assignment syntax, and the side-effects of the shell spawning subshells. You can either capture stderr or stdout but not both: the other stream needs to redirected into file (perhaps a FIFO).
# a function for testing
your_command() { sh -c 'echo "this is stdout"; echo "this is stderr" >&2'; }
errfile=$(mktemp)
out=$( your_command 2>|"$errfile" )
err=$(< "$errfile")
rm "$errfile"
echo "out: $out"
echo "err: $err"