I suppose you could say "in order to" in the first group, and "by which" in the second.

I have come here (in order) to see her. Some action takes place to achieve the result of being able to perform the second action. You cannot say "I have come here by which to see her".

Hydrogen and oxygen unite, by which they form water. The process of uniting itself has the result of achieving the transformation to water. It sounds weird if you say "in order to form water" because it's not exactly a plan: "Hey oxygen, let's unite and be water for a change".

Elements combine, by which (process) they become a compound.