I think all the details in your question have a role in this, and the proportion of contribution depends on the university and social environment in which the student is present.
It is easy to blame many of the factors mentioned on student failure. It boils down to student responsibility in the end. By properly allocating their time for studies, the student can stay away from bad friends or sports addiction. For properly guiding the student to make the right decisions, families (example parents or elders) have a responsibility at least during the first or second year of the student's university experience. Existence of "Unqualified" professors is not within many people's control and the student will have to deal with that issue (if the issue is real) on a case by case basis.
Bad friends is probably the worst culprit, followed by uncontrolled internet, sports addiction, poor family guidance, ... University-related issues are lower on the list but they are easy targets to blame for someon's failure to do well.