I always assumed it was closer to the United Nations on the Federation of planets level
Not really. The United Nations is not a sovereign state -- it does not possess its own distinct population of citizens, territory over which it is sovereign, a government capable of making binding law, its own military, or its own society in any sense. The United Federation of Planets, by contrast, possesses all of the traits that comprise a sovereign state: its own citizenry, its own territory over which it is sovereign, a government legally empowered to make binding law, its own foreign policy, a system of civilian courts and prosecutors, and its own military in the form of Starfleet.
and that Starfleet was like the deployable force. The UN has NATO peacekeepers who mostly (but not always) act as a military
Okay we got a lot of misconceptions to unpack here.
First off, the United Nations (U.N.) and the North Atlantic Treaty Organization (NATO) are absolutely
not the same thing, like at all. They are two entirely different international organizations, whose Members comprise a different set of sovereign states, with two different Secretaries-General and two different secretariats supporting their respective Secretaries-General.
The U.N. is an intergovernmental organization whose role is, in essence, to be the international forum through which all of the world's states (more or less) may conduct diplomacy in order to avoid war. NATO, by contrast, is a
military alliance designed to provide its Member States (the U.S., Canada, and most of Europe) with a significant security deterrent against Russian (initially Soviet) expansionism.
Neither the U.N. nor NATO possess their own military forces. For NATO, what it does is it provides a system whereby the military forces of its Member States may be integrated into a common command structure so as to unify them in the field; the Member States remain the sovereigns, and have the authority to withdraw their military forces from the NATO unified command structure at any point. The Member States' military forces' primary allegiance remains at all times to the Member State, not to NATO.
The U.N. has once been able to establish a common command structure and recommend that its Member States send expeditionary forces to join that common command structure -- when the USSR boycotted a Security Council vote and so the U.N. was able to establish United Nations Command in the Korean War. However, that hasn't happened since, and like with NATO, the military forces made part of United Nations Command were seconded to it and still owed primary allegiance to their Member States, not the U.N.
U.N. Peacekeepers are also a form of common command structure that U.N. Member States may second some of their forces to, but they are both more limited in scope and in effectiveness than traditional military forces. Once again, they are not themselves military forces and the military forces that are seconded to them remain under the allegiance of the Member State that sent them.
At all times, the commander-in-chief of the Member State may withdraw any forces they have seconded to NATO or U.N. command structures and those forces must legally obey their own commander-in-chief.
While it has on occasion authorized NATO to undertake military missions (such as the occupation of Afghanistan), the U.N. does not use the NATO command structures because the goals of the U.N. and the goals of NATO are not compatible. NATO is not a part of and is not subordinate to the U.N.