The Philippines had long been a Spanish colony However, the British came to blows with the Spanish as a result of the Seven Years War. The French and Spanish thrones were related to one another. Spain joined the war in its later stages, but it meant new targets for the British.
The Royal Navy and East India Company had forces available in India after the fall of Pondicherry. They built up their forces in utmost secrecy in order to gain the element of surprise. They landed at Manila in 1762 and took the city without too much fighting. The Spanish retreated in to the interior. One consequence of this strike was that Spain attacked Britain's ally of Portugal.
The fighting on the islands actually continued until after the Treaty of Paris - it took a long time for the results of the war to reach the Philippines. The British were supposed to withdraw fully in 1764 but a force actually remained on the Sulu Islands until 1773. Part of the deal was that the British would return Cuba and the Philippines in exchange for Florida and for the Spanish withdrawal from Portugal.
A number of the East India Sepoys and other mercenaries actually deserted over the two year occupation and set themselves up on the islands - adding an unusual mix into the Philippine countryside.