In X2, both Scott Summers (Cyclops) and Charles Xavier (Professor X) are alive at the end of the film. Here's why:
* Cyclops: While he is gravely injured by Wolverine in a battle, he's ultimately saved by Jean Grey. He survives and is seen recovering at the X-Mansion.
* Professor X: He's briefly knocked out by Magneto in a psychic battle but is alive and well at the end of the movie. He takes on the task of uniting humans and mutants.
However, you're probably thinking of the events of X-Men: The Last Stand, where both Scott and Xavier have different fates.
* Cyclops: He is killed by Jean Grey (now Dark Phoenix) after she loses control of her powers.
* Professor X: He's killed by Jean Grey as well, but in a separate incident. He is later resurrected in the X-Men: First Class timeline.
I hope this clarifies the situation for you!