That's the same に as the initial one. に indeed means ~のために as a result in those two examples, but it totally depends on the context whether に can have that meaning or not.
cf.
味方が勝つために、僕が敵に出来ることを、僕は知りたかった。
The speaker doesn't want to do something for the sake of the enemy, right?