How did Anakin Skywalker lose at the end of Revenge of the Sith?

I think he was powerful than obi wan. Why do the good guys always win in movies and Tv series?
How did Anakin Skywalker lose at the end of Revenge of the Sith?
Post Opinion