Automatically redirect a page to a category that share the same slug

Well you can just turn the code 180 degrees from the linked question and problem solved.

Just kidding.

I would start with getting the current page slug, using that slug search for a category that has that slug, if found, redirect to it

add_action('template_redirect', 'bt_redirect_page_to_category');
function bt_redirect_page_to_category () {
    // if we are not in page, no need to run the code
    if (!is_page()) return;

    // get current page object
    global $post;

    // get page slug
    $slug = $post->post_name;

    // the term taxonomy
    $taxonomy = 'category';

    // get category
    // you can use get_category_by_slug(), but I prefer get_term_by()
    $category = get_term_by('slug', $slug, $taxonomy);

    // if no category found, no need to continue with the code
    if (empty($category)) return;

    // found category so we can redirect
    if ( wp_safe_redirect( get_term_link( $category, $taxonomy ), 301 ) ) {
        exit;
    }
}