Pulling posts tagged with similar title name

First of all, don’t use query_posts

Form Codex:

Note: This function isn’t meant to be used by plugins or themes. As
explained later, there are better, more performant options to alter
the main query. query_posts() is overly simplistic and problematic way
to modify main query of a page by replacing it with new instance of
the query. It is inefficient (re-runs SQL queries) and will outright
fail in some circumstances (especially often when dealing with posts
pagination). Any modern WP code should use more reliable methods, like
making use of pre_get_posts hook, for this purpose.

(the picture there is by this site mod @Rarst.

Main problem is that the_title() echos the title, does not return the title.

For that scope you have to use get_the_title().

Also, PHP is not javascript, don’t use var before the variables:

<?php
$project_title = get_the_title();
$query = new WP_Query( array(
  'tag_slug__in' => array( $project_title )
) );
while ( $query->have_posts() ) : $query->the_post(); ?>