Remove the Parent category from the permalink but leave the child category

I think, there are two things to be resolved:

1) You need that posts (and other post types) also followed that command, so use both:

add_filter( 'post_link',      'remove_parent_category', 10, 3 );
add_filter( 'post_type_link', 'remove_parent_category', 10, 3 ); 

2) but then categories also need to have changed url, so use:

add_filter( 'category_link', 'remove_parent_category_2', 10, 2);
function remove_parent_category_2($termlink, $term_id )
{
    return implode("https://wordpress.stackexchange.com/", array_unique(explode("https://wordpress.stackexchange.com/", $termlink)));
}

after that, go to SETTINGS > PERMALINKS > SAVE and see if it works.

btw, what I suggest, is (after backup of database) just to remove those categories from categories at all (from WP dashboard > categories), and WP will do everything itself, without need for custom codes.