Query for getting posts with their custom fields data in WordPress

You can use this code,

$args = array(
    'cat' => 4, // Category ID
    // 'category_name' => 'staff', // Category Name
    'posts_per_page' => -1,
)

// The Query
$query = new WP_Query( $args );

// The Loop
while ( $query->have_posts() ) {

    $query->the_post();

    $thumbnail_image = get_post_meta( get_the_ID(), 'thumbnail_image', true );
    $first_image     = get_post_meta( get_the_ID(), 'first_image',     true );
    $second_image    = get_post_meta( get_the_ID(), 'second_image',    true );
    $third_image     = get_post_meta( get_the_ID(), 'third_image',     true );
}