Need to adjust condition to say if I’m pulling categories from a post, to pull only the first one

Currently you are looping through the array of categories retrieved with get_the_category() and for each category you retrieve two posts. In stead I understand you want to pull two posts from one category only.

To do so, you would have to remove the foreach loop and in stead define $category as the first category in the array only, like this: $category = $categories[0];