Output a specific link in WordPress post if the single post’s category’s name contain certain word

You should remove the single quotes around the expression otherwise it will be treated as a string.

$firstCategory = '$category[0]->cat_name';

Should be changed to:

$firstCategory = $category[0]->cat_name;

Then you can try basic debugging like printing the output of the $category and $category[0]->cat_name.