Add row after three columns

Here’s an idea of what I think you could do if I understand the problem correctly:

<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">
        <div class=" entry-content">
        <?php
        if ( have_posts() ) {
            $post = $posts[0];
            $c = 0;
            $i = 0;

            while ( have_posts() ) {
                the_post();

                // start a new row for the first post and every three posts
                if ( ! $paged && ( 0 == $c || 0 == ( $c % 3 ) ) ) {
                    get_template_part( 'template-parts/content', 'aktuelles-first' );
                    echo my_code_open_row();
                } else {
                    get_template_part( 'template-parts/content', 'aktuelles' );
                }

                // close the opened divs above
                if ( $i > 2 ) {
                    echo my_code_close_row();
                    $i = 0; // Reset the row close counter
                }

                $c++;
                $i++;
            }

            // Close the row if we never get to the row closing
            // before we leave the loop
            if ( $i < 2 ) {
                echo my_code_close_row();
            }
        }
        ?>
        </div>
    </div>
    </main><!-- #main -->
</div><!-- #primary -->
<?php
function my_code_open_row() {
    return <<<HTML
    <div class="accordion">
        <div class="row">
HTML;
}

function my_code_close_row() {
    return <<<HTML
        </div>
    </div>
HTML;
}