Harry already tried casting the highly illegal Cruciatus Curse twice against Snape earlier in the fight. Snape mocked him, saying he lacked the ability to cast Unforgivable Curses.
"Cruc - "
But Snape parried the curse, knocking Harry backward off his feet before he could complete it; Harry rolled over and scrambled back up again as the huge Death Eater behind him yelled, "Incendio!" Harry heard an explosive bang and a dancing orange light spilled over all of them: Hagrid's house was on fire.
"Fang's in there, yer evil - !" Hagrid bellowed.
"Cruc -" yelled Harry for the second time, aiming for the figure ahead illuminated in the dancing firelight, but Snape blocked the spell again. Harry could see him sneering.
"No Unforgivable Curses from you, Potter!" he shouted over the rushing of the flames, Hagrid's yells, and the wild yelping of the trapped Fang. "You haven't got the nerve or the ability."
Harry, the narration tells us, “felt no fear at all, but only rage and contempt.” He wanted Snape to hurt. He wanted him to hurt quite badly. He didn’t know how to cast the Killing Curse, but he cast the worst curse he knew he could perform. It’s likely in the moment he was aware he was attempting to kill Snape, or very least that his death was likely to result from his actions. He was an angry, 16-year-old boy who watched one of his worst enemies betray and murder his dearest mentor, while he sat there powerless to act.
A year earlier, when Harry had also run down an opponent who had killed a man he loved and cast Unforgivable Curses, he was pretty explicit about his intentions.
“SHE KILLED SIRIUS!” bellowed Harry. “SHE KILLED HIM — I’LL KILL HER!”
You are correct that this goes against Harry later using the disarming charm to beat Voldemort. But in both instances he was a young man under severe emotional turmoil. Harry matures and learns to deal with his grief more mature ways, and extend mercy to his enemies. That’s character growth, kids!