Display content from custom post type if match to main post category

A better solution than the one you found on your own, would be to only retrieve matching posts in the first place. As is, you are potentially retrieving the wrong data. With your code (your solution), what happens if the two posts in the result set don’t match? You get no output at all.

Your description/code is a bit disjointed so I am guessing at things a little, and this is untested, but I think that what you want is:

$category_main = get_the_category();
$cat_slug = $category_main[0]->slug;
// echo $cat_slug; // This is just to see if I got the right output
$args = array( 
  'post_type' => 'Course', 
  'posts_per_page' => 2,
  'category_name' => $cat_slug,
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) {
  $loop->the_post();

  $category_course = get_the_category();
  $cat_slug_course = $category_course[0]->slug;
  //   echo $cat_slug_course; // This is just to see if I got the right output
  echo '<br />';    
  the_title();
  echo '<div class="entry-content">';
  the_content();
  echo '</div>';
}