Can’t get the columns of galleries when the user set the column number to 3 if there are 2 galleries?

OK, I just tested this a little further. Indeed, if you select 3 columns (the default WP gallery column count) and do a var_dump( $gallery ); you will see that there is no column key in the array. (like for example with 4 columns ["columns"]=> "4").
You can maybe do something like this:

$gallery = get_post_gallery( $post->ID, false );

if (array_key_exists( 'columns', $gallery )) {
    echo $gallery['columns'];
} else {
    echo 'default WP 3 columns';
}