If you want multiple hooked functions (duplicated or not), each of them need a unique unused name:
add_action('template_redirect', 'my_custom_message_one');
function my_custom_message_one() {
if ( is_checkout() && ! is_wc_endpoint_url() ) {
wc_add_notice( __('This is my 1st custom message (for all)'), 'notice' );
}
}
add_action('woocommerce_before_checkout_form', 'my_custom_message_two');
function my_custom_message_two() {
if ( ! is_user_logged_in() ) {
wc_print_notice( __('This is my custom message (for non logged users)'), 'notice' );
}
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.

Or you can use one function and 2 notices merged in the same function:
add_action('template_redirect', 'my_custom_message');
function my_custom_message() {
if ( is_checkout() && ! is_wc_endpoint_url() ) {
wc_add_notice( __('This is my 1st custom message (for all)'), 'notice' );
}
if ( ! is_user_logged_in() && is_checkout() && ! is_wc_endpoint_url() ) {
wc_add_notice( __('This is my 2nd custom message (for non logged users)'), 'notice' );
}
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
