The brief answer to this question is that Custer was trying to kill the Indians, so no one should be surprised that they attempted to defend themselves by killing him. The Indians in fact had very little choice: Custer had attacked them, and they could scarcely have ignored him.
Custer was killed at the battle of the Little Bighorn, on June 26, 1876, the greatest Indian victory in the Great Sioux War of 1876-1877. He made the elementary mistake of attacking a force of warriors three times larger than the 600 or so men he was leading at the time over unfamiliar terrain that was entirely unsuited for the sort of cavalry tactics his troops were trained in. He had also refused reinforcements, including a battery of Gatling machine guns that would probably have caused the Indians to avoid combat.