If you use return
then your loop will not work properly. You can try the code this way:
<?php while($portfolio->have_posts()) : $portfolio->the_post(); ?>
<?php $term_class="";
$categories = get_the_terms($post->ID, 'project_type');
foreach($categories as $category){
$term_class .= ' ' . $category->name;
}
?>
<div class="portfolio-tile <?php echo trim($term_class) ;?>">
<?php the_post_thumbnail('medium' ); ?>
</div>
<?php endwhile; ?>
</div>
<?php wp_reset_query(); ?>