A Spanish ship seized the men off the coast of Somalia Wednesday after their boat capsized during their alleged attempt to hijack a Panamanian-flagged vessel .