Loop Offset for tag based “Related Posts”

doing 3 separate queries is unnecessary and inefficient, do one query for all 12 posts and output your container markup every fourth post.

$args = array(
    'tag__in' => $tag_ids,
    'post__not_in' => array($post->ID),
    'posts_per_page'=> 12
);
$my_query = new WP_Query( $args );
if( $my_query->have_posts() ):
?>  
    <div class="container">
    <?php
    while ( $my_query->have_posts() ) : $my_query->the_post();

        the_title();

        // if this is not the last post
        // and remainder of current post plus one then divided by four is zero
        // close the container and open a new one
        if( $my_query->current_post != ( $my_query->post_count - 1 ) && ( ( $my_query->current_post + 1 ) % 4 ) == 0 ):
            ?>
            </div>
            <div class="container">
            <?php
        endif;

    endwhile;
    ?>
    </div>        
<?php
endif;