You have to mention the issue in a commit before you mark the issue as fixed. So when you mark the issue fixed it gets set to next build, and on the next build that succeeds you get the fixed in build set - assuming the build that succeeded was the one linked to that youtrack project.
For the longest time you had to have the issue marked fixed in youtrack before any builds would cause the fixed in build to be set.
So, commit with issue ID, then mark issue fixed in next build. You can refresh the teamcity integration from the issue so it picks up the build.
First I fix the issue in the code. Commit the change to source control. Then in YouTrack - I mark the issue "Fixed"
You can also manually link the issue to the commit.