The Naruto series is set on fictional terrestrial blue planet called Earth, which includes at least a continent that is divided into a number of different countries.
In the AWA fics, the Elemental Nations is under the protection and are allies of the All Worlds Alliance.
In the XP4 fics, the Elemental Nations are allies with the Heroes Coalition.
From countless millennia worth of war amongst Earth's population, the bloodshed lead to the planet's God Tree absorbing it to subsequently grow a Chakra Fruit, which was forbidden for humans to touch. The God Tree was revered by some cultures; humans used to worship it as a sacred pillar that extended into the heavens and remained ambivalent to all conflict. The Ōtsutsuki clan considered Earth as the the region Kaguya Ōtsutsuki was in charge of. Arriving to the planet with a portion of the clan in search for fruit of the God Tree, she ate it, resulting in her manifesting chakra which she used to bring an end to the constant wars. Afterwards, she had twin sons, Hagoromo and Hamura, whom were the first humans born with chakra.
Becoming corrupted by chakra, Kaguya began turning the planet's Infinite Tsukuyomi victims into an army of White Zetsu, and integrated with the God Tree to become the Ten-Tails in order to reclaim the chakra her sons inherited. Causing havoc to the planet, the beast was sealed away by the twins. Believing chakra was a power that linked everything in the world, Hagoromo set out to spread the message to the people of the land, during which his teachings became known as ninshū. This act eventually lead to the planet's population acquiring chakra, which they became dependent on possessing to sustain living. Hagoromo's eldest son Indra, weaponised chakra, which lead to the creation of ninjutsu and as a result the Shinobi World.
During the Warring States Period, the countries of the world were uniformly small, and constantly hired shinobi clans to fight their battles for land. The constant warfare lead to the average lifespan of the mercenaries to thirty years. Hashirama Senju offered the Uchiha clan a peace treaty, which Madara accepted. The Uchiha and Senju clan allied with the Land of Fire to establish a shinobi village. Other clans would soon join the village, and it would later become known as Konohagakure. Clans in other countries that were fearful of the combined might of the Senju and Uchiha, adopted the ideology and created their own villages. This system lead to the creation of many shinobi villages, with the Five Great Shinobi Countries standing out as the strongest.
Tension between nations lead to the First Shinobi World War, which involved the majority of nations. It ended with an armistice treaty, after all of the Five Great Nations had been seriously damaged. Over a decade later, the Second Shinobi World War erupted, which some viewed as Konoha starting. When the Third Shinobi World War broke out, it involved shinobi from every land, and ended with an armistice agreement between Konoha and Iwagakure.
Countries operate as separate political entities and are presumably all monarchies, ruled by daimyōwho stand as a ruler for the entire country. Hidden Village heads are the generals that take care of shinobi matters. The Naruto world is similar to feudal Japan in many aspects; those countries maintain balance between themselves through nothing but power. Treaties are periodically signed, but they are generally not worth much more than the paper they are written on.