Different front page for logged in and logged out user but the same URL in WordPress

If you’re just trying to display different content to logged-in vs. logged-out users, I’d recommend using the the_content filter.

add_filter( 'the_content', 'wpse_387084_content_selector' );
function wpse_387084_content_selector( $content ) {
    if ( is_front_page() && is_user_logged_in() ) {
        $page = get_post( 2516 );
        $content = $page->post_content;
    }
    return $content;
}

The above code assumes that you’ve set the “Page on Front” to the page with ID 2, and that’s what you want to show to unauthenticated users.