In general, 「〜ようにする 」 means that the subject is doing something such that 〜 will happen.
So in this case, the subject 私 is doing something (the something is implied in this case) so that he will be avoiding K's room. In other words, 私 is taking measures to avoid K's room.
The て形 has a lot of uses, all of which show that the two clauses are linked somehow with the first either coinciding with our preceding the second. I personally think that just remembering that is enough to make sense of it in most cases.
I do believe however that one of the uses of the て形 when joining clauses in to show that the second was unexpected given the first. Edit: I think this is just a sequential use.
I was making every effort to avoid K's room but in the process I ended up running into him in the street/hall.
This translation was kindly pointed out to me in the comments as incorrect. I misunderstood the meaning of 自分を見出す. A more accurate translation is below.
I was making every effort to avoid K's room and in the process, I found myself in the middle of the street.
I used "every" to strengthen the effort that I think わざと adds. Including "on purpose" is redundant in the English I think.
こんな風に is "in the process" though "in this manner" might be more accurate.
If anyone believes I am incorrect anywhere, I welcome criticism.