Castañeda graduated from the Philippine Military Academy on 15 November 1915, and from the Infantry School at Fort Benning, United States in 1940. He became President Manuel Quezon's aide-de-camp that same year and fought with the United States Army Forces in the Far East during the Battle of Bataan. He survived the Bataan Death March in 1942 and began organizing resistance against Imperial Japanese occupation, most notably the Fil-American Cavite Guerrilla Forces shortly thereafter. In 1944, the Japanese-controlled Second Philippine Republic appointed him Governor of Cavite. After seven months in office, the Japanese became aware of his guerrilla affiliation and attempted to arrest him; he was able to elude his would-be captors and joined his comrades in the field and he engineered along with his FACGF officers and in coordination with the US 11th Airborne Division General Swing and Col.Jay Vanderpool the battle for the liberation of the province of Cavite