Proper way to create a redirect?

I have a redirect that works:

add_action('template_redirect', function () {
    if (!bricks_is_builder_main() && !is_admin()) {
        // Redirect logged-in users away from login or forgot password pages
        if (is_user_logged_in() && is_page([46440, 46121])) {
            wp_redirect(site_url('/my-account/'));
            exit;
        }

        // Redirect non-logged-in users from account or checkout pages to a custom login page
        if (!is_user_logged_in() && (is_account_page() || is_checkout())) {
            wp_redirect(home_url('/log-in-or-create-an-account/')); // Change to your custom page URL
            exit;
        }
    }
});

BUT if I try to edit the pages bricks loads the redirected page not the one I want to edit… what am I doing wrong?