What I want to accomplish is to attach all lines to the edges of the triangles, and then if I move a triangle, the associated lines move with it - they stay anchored to the respective edge of the triangle.
For example if I move the triangle on the right, this should happen:
Can you please help me how to accomplish this without having to move the lines manually?
Essentially, it sounds like you are asking if there is a way to group anchor points in AI and I am afraid that there is not. You will have to select the points with the triangles as @Jacob Bugge has stated.