~고자 (~go-ja) – so as to… (someone) did something
This is quite similar to ~(으)려고, ~(으)러 and ~도록, we would verbs before and after these grammar particles.
You can look at the second action after ~고자 to be the explanation/justification for the first action.
난 집에 근처 있는 똑볶이집으로 똑볶이를 먹고자 갔어.
I went to the rice cake shop near my house so as to eat spicy rice cakes.
선생님은 우리 학생들이 잘 이해하고자 진짜 열심히 가르쳐 주셔서 너무 감동했어.
The teacher is very hardworking in teaching us so as to help us students understand it well so it was really touching.