How did the Philippines gain their independence? The Philippines had many different countries who tried to control them at various times:
Ultimately, the Philippines gained independence through the Philippine American War and through the U.S. signing a treaty at the end of World War II after the US had taken the Philippines back from Japan.

The Philippines signed a treaty to become independent after a long road to get there. The Philippines had to fight for their independence from outside occupation twice, over a period of almost 50 years.
The Philippines still had to gain their independence to become their own country.
The Filipino people were under the impression that the American government was going to assist them in forming their own government, but soon came to find that the U.S. quickly instituted its own form of military government which took control of the entirety of the Philippines.
This control over the Filipino people lasted until 1946, when the Filipino people finally achieved their independence through revolution on, quite fittingly, July 4th.
The Filipino revolution was led by Emilio Aguinaldo, who fought with the Filipino people to establish a free Filipino state after the American occupation of the country did not go as the people of the Philippines had assumed it would.
In the early 1940s, however, there was a power shift that neither the Filipino people nor the United States were expecting.
Even after granting the Philippines independence there continued to be criticisms against the United States government for its war tactics in both the Philippines as well as during the Second World War. Regardless of the criticism against the U.S., this is how the Philippines established independence, and they were their own nation from that point forward.