Which lecture are you referring to? echo writes its arguments to standard output so the second command wouldn’t do what the comment suggests but create a file with “grep root /etc/passw” in it.
With >> .bashrc you say that you want to append the contents of standard output to the file .bashrc. echo puts that content into standard output - in this case DB_USER=mosh.