How do I dynamically populate a shortcode with a variable from URL?

To use get_query_var, you must first register the query variable with the query_vars filter.

add_filter( 'query_vars', 'wpse251014_query_vars' );
function wpse251014_query_vars( $query_vars ) {
    $query_vars[] = 'pid';
    return $query_vars;
}

Reference: get_query_var