Distribute Gallery Images Every nth in Loop

As I pointed in the comments, if for example you’re displaying 9 posts per page, which means there would be 3 gallery images shown per page, and you want page #1 to show images 1-3, page #2 to show images 4-6, and so on, then you would want to paginate the gallery images:

// the number 3 below is the position where the image is to be added to
$paged = max( 1, get_query_var( 'paged' ) ); // get the current page number
$per_page = floor( max( 1, get_query_var( 'posts_per_page' ) ) / 3 );

$counter = 1;
$img_ct = ( $paged - 1 ) * $per_page; // start showing images of this index

And that would replace this part:

$counter = 1;
$img_ct = 0;

Also, you should use if ( ! empty( $images ) ) instead of just if ( $images ).