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];