How to get a count of all posts in foreach loop and split into fourths

I had a similar problem couple years ago. Here’s a gist I’ve published, which shows the basic idea how I solved the problem,https://gist.github.com/koskinenaa/4d8461116885c0e64d5ca167ae53434d

Applying the gist to your situation I think the solution could be something like this. I didn’t test this so it might require some tweaking, but it should at least point you to the right direction. Of course you need to add relevant css for the ul elements to position them next to each other.

In my example I moved the term and post queries to their own helper functions, but this is just a matter of preference.

function archive_categories( string $tax ) {
  $categories = get_terms($tax);
  return ( $categories && is_array($categories) ) ? $categories: array();
}

function archive_category_posts_query( string $tax, string $term ) {
  $args = array(
    'post_type'   => array('custom_post', 'custom_post', 'custom_post'),
    'numberposts' => -1,
    'orderby'     => 'title',
    'order'       => 'ASC'
    'tax_query' => array(
      array(
          'taxonomy' => $tax,
          'field'    => 'slug',
          'terms'    => $term,
      ),
    ),
  );
  return new WP_Query($args);
}

$categories = archive_categories('archive_category');
$col_count = 4;

foreach ($categories as $category) :
  $category_posts_query = archive_category_posts_query($category->taxonomy, $category->slug);
  $post_count = $category_posts_query->found_posts;
  $posts_per_col = ceil( $post_count / $col_count );
  $i = 0;
  ?>
  <div>
    <a data-toggle="collapse" href="#<?php echo $category->slug; ?>">
      <h3><?php echo $count; ?><?php echo $category->name; ?></h3>
    </a>
    <div class="collapse" id="<?php echo $category->slug; ?>">
      <ul>
        <?php foreach ( $category_posts_query->posts as $category_post ) : 
          if ( $posts_per_col === $i ) {
            $i = 0; 
            echo '</ul><ul>';
          }
        ?>
          <li>
            <a href="<?php esc_url( get_the_permalink( $category_post->ID ) ); ?>"><?php echo esc_html( $category_post->post_title ); ?></a>
          </li>
        <?php $i++; endforeach; ?>
      </ul>
    </div> <!-- collapse -->
  </div> <!-- collapse wrapper -->
<?php endforeach;

EDIT 5.2.2020

Categories into columns? You mean something like this?

$categories = archive_categories('archive_category');
$category_count = count( $categories );
$col_count = 3;
$categories_per_col = $category_count > $col_count ? ceil( $category_count / $col_count ) : 1;
$column_index = 1;

echo '<div class="row">';
foreach ($categories as $category) :
  $category_posts_query = archive_category_posts_query($category->taxonomy, $category->slug);
  if ( $column_index > $col_count ) {
    $column_index = 1;
    echo '</div><div class="row">';
  }
  $classes = array(
    'column_1_of_' . $col_count,
    'column-' . $column_index,
  );
  ?>
  <div class="<?php echo implode( ' ', $classes ); ?>">
    <a data-toggle="collapse" href="#<?php echo $category->slug; ?>">
      <h3><?php echo $category->count . ' ' . $category->name; ?></h3>
    </a>
    <div class="collapse" id="<?php echo $category->slug; ?>">
      <ul>
        <?php foreach ( $category_posts_query->posts as $category_post ) : ?>
          <li>
            <a href="<?php esc_url( get_the_permalink( $category_post->ID ) ); ?>"><?php echo esc_html( $category_post->post_title ); ?></a>
          </li>
        <?php endforeach; ?>
      </ul>
    </div> <!-- collapse -->
  </div> <!-- collapse wrapper -->
<?php $column_index++; endforeach;
echo '</div>';

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)