Get amount of CPT with a certain custom field value

Well, it returns wrong number, because you’ve coded it exactly in that way 😉

Your WP_Query is correct. So when there are no posts matching your conditions, then you get 0.

But when there are such posts, then… you ignore the query completely and return wp_count_posts as result… But…

This function returns an object, whose properties are the count of each post status of a post type. It does NOT count posts in given query – and TBH – in your case it couldn’t do that (how should this function now what query to count posts of?)

So here’s your code in correct form:

add_shortcode('count_usr_msg','count_usr_msg');
function count_usr_msg($atts){
    $usr_id = $atts['usr_id'];
    $args = array(
        'post_type'              => 'usr_msg',
        'meta_query'             => array(
            array(
                'key'     => 'posted_user_id',
                'value'   => $usr_id,
                'compare' => '=',
            )
        )
    );

    $usr_msg = new WP_Query( $args );

    return $usr_msg->found_posts;
}

Instead of checking some conditions, we just use found_posts, which contains:

The total number of posts found matching the current query parameters

and return it as a value.