I did a quick look in the source code. I didn't see anything in the courses controller, which is the one being called, that handles favorites (it's documented as an include), so it's probably handled by the code for the favorites controller, which would make sense in the context of keeping related code together in one file. In that code, it's coded as @current_user rather than @user, probably because the favorites are only returned for the current user -- which is overridden by the as_user_id= parameter, but I guess not by just asking for a user.
Being able to figure out why it's doing what's it's doing is not the same as saying it's doing what makes the most sense.