1. Some students think they can skip class and catch up through self-study, but actually they can't. The same I'd-rather-be-partying attitude that stops them attending lectures also stops them finding time to self-study. College is the first time students' time management is put to the test, and some students can't handle it. Giving them some external motivation to get out of bed does them a favour, in the long term.
2. Some courses are discussion-and-debate oriented. Less so in engineering, moreso in arts subjects. If Socratic debate is a key part of the class, students who don't show up will of course lose grades - and accurate record keeping makes sure that's done fairly.
3. Some governments require certain reporting to ensure people getting student visas are, in fact, students. Taking attendance for foreign students is one way to satisfy this.
4. When someone fails a course they'll often lodge an appeal. Perhaps they'll say the course was badly taught, or the exam covered material that wasn't in the lectures. Knowing whether the student attended the lectures helps adjudicate such complaints fairly.
A highly ranked university that attracts smart, self-motivated students has less reason to take attendance - whereas a university with lots of students skipping class, failing and complaining has more reason.
As for laboratory exercises in the physics department, they were in theory compulsory but still no one checked. The final year included a long experimental project that had to be documented and conclusions defended in a viva. Again no one formally checked that we actually did it but as we were grouped into small teams for this anyone who didn't pull their weight would have been reported by their fellow students and would not have had access to the experimental results which would have made it difficult to write it up and defend.
- Some students are "sponsored" by scholarships or organizations that request attendance data. - I want to know the attendance record for a student who is asking for an extension, or extra-credit work, or some other informal accommodation. - I like to draw fancy graphs correlating attendance and final grades.
But other than that, I don't care if students are in class or not. They're adults. Learning is their responsibility.