The UN's ability to stop a war is possible but not guaranteed, as its power is limited by the national interests of member states and the political divisions within its primary decision-making body, the Security Council. The UN's effectiveness depends heavily on having a broad consensus to act and the political will of powerful nations to contribute resources and military force.
Russia is a member of the Security Council.
So if the invasion of Ukraine is illegal....why wasn't it stopped in 2014 by the UN? Or why wasn't it stopped in February of 2022? The reason is that such is merely a misnomer.