There is an element of luck in life, people are not always rational, hiring is more art than science. So it is perfectly possible that you could be a better canadidate in everyway than someone else and not get the job because the interviewer was in a bad mood or was distracted when it came to your interview. The only way to deal with that is keep trying.
Also you seem too focused on just your CS skills, there are lots of characteristics to be considered when hiring someone beyond just technical skills. For instance how you get along with people, the attitude you bring to the workplace, how you cope with the management style of the company, etc... Fact is even if a candidate has better technical skills if s/he makes the people they work with or around less productive because of poor communication, poor inter-personal skills or poor attitude they will not be an asset to the company.
It also depends on the work environment if the company culture is highly competitive, and fast-paced someone with a strong A-type personality would be desirable, whereas they could be very disruptive to a more low-key cooperative workplace. So it is impossible to be the perfect candidate for every position. Likewise its completely possible for nothing to be "a problem" but you still not be suitable for that particular job.
You can see from the response of various people on this thread that you may need to work on your interpersonal skills since you seem to generate conflict quite easily which would be a problem for any job that requires a lot of teamwork. You could probably also work on your communication & personal presentation since your posts are full of spelling mistakes and poor grammar. You might think it doesn't matter but the other people on this forum are potentially future collegues or employers so it is worth it to make a good impression.
Since you are getting to the final rounds chances are your overall quality taking into consideration all the important characteristics is going to be very similar to the other candidates. Sure they might not have the technical skills you have but they may have a more suitable temperament or better social-skills. At that point it is often down to chance or subconscious biases of the interviewers than any "real" differences between candidates.