They are not necessarily two 'pilots'. Instead, there's a pilot and a gunner. The gunner position operates the helicopter's weaponry, leaving the pilot to remain focused on flying the helicopter. On many modern examples, both positions are equipped (and trained) to both fly and operate weapons should the need arise.