What are the differences between comment_form_logged_in_after and comment_form_after_fields?

Am I right in assuming that the first is for logged in users and the
second for anon users?

Yes.

And “a picture is worth a thousand words”; so, see and compare the sample output/previews below. (The theme used is the Twenty Nineteen theme.)

1. comment_form_logged_in_after

  • WordPress runs this hook if the current user is logged-in.

  • You can use this hook to add something after the opening <form> tag — or more precisely, after whatever stuff added via the comment_form_top hook — and that something would be displayed before the comment field (which is the text box/textarea for entering the comment text/content).

  • This hook is basically a shortcut to using the comment_form_top hook with is_user_logged_in():

    // Note that WordPress runs comment_form_top regardless the user is logged-in or not.
    add_action( 'comment_form_top', function () {
        if ( is_user_logged_in() ) {
            echo 'comment_form_top: is logged-in<br />';
        } else {
            echo 'comment_form_top: not logged-in<br />';
        }
    } );
    

enter image description here

2. comment_form_after_fields

  • WordPress runs this hook if the current user is not logged-in.

  • You can use this hook to add something in between the last field and the submit button in the form — in the preview below, the last field is the one below the “Save my name, email, …” (i.e. cookies consent).

  • This hook is similar to comment_form_before_fields which you can use to add something in between the comment field and the name field in the form.

So referring to this answer, the add_my_custom_field_to_comment_form function is hooked to both comment_form_logged_in_after and comment_form_after_fields so that the custom field would appear for both authenticated and non-authenticated users.

Why so: When the user is not authenticated, extra form fields are displayed after the comment field. When the user is authenticated, then the extra form fields are not displayed by default. (Extra form fields are those other than the comment field; see $fields.)

enter image description here

(Note that this answer covers the default behaviors in WordPress. Plugins and themes may change any of the behaviors, such as using CSS/JavaScript to change element’s position/visibility/etc.)

And for all the currently available hooks for the comment form (i.e. comment_form()), check this.