Hamas is rushing to reassert control over the territory it has ruled since 2007. Its leaders are exuberant—at least in public. In private, they are arguing bitterly. The war has deepened a longtime struggle between the group’s political and military leaders and has saddled it with enormous challenges.