I do not have a solution, but two points of view. Disregarding either is simplistic.
Good teachers have good attendance
In this perspective, it is your duty as a teacher to make the education so good that students want to attend. Maybe you are just lecturing, not engaging them, teaching at too low or high level?
A student responsibility to be there
In this perspective the teacher offers their expertise and knowledge, and the student can choose to make use of it or not. Some students lack the skills or the motivation to get through and you must learn to accept this. You can not save everyone. So, if the students choose to not attend, that is their choice as an adult. Who are you to critize them?
Complicating factors
There are all kinds of issues beyond the two named above. Effective teaching puts the learners outside their comfort zone, so good teaching is not always purely pleasant; it is engaging and does not hurt, but requires energy to participate in and puts one to test. The levels of participation requires and stress that students accept varies from person to person, so most likely the level you choose will not suit everyone.
There are also all kinds of habits and expectations in play. Students might see their position as one who sits in on lectures and absorbs knowledge, or as someone who is responsible for their own learning, or in a variety of other ways. These different positions interact with your teaching methods in various ways, leading to presence, absence, learning or not learning.
So all I can say at this point is good luck and try out various teaching methods and ways of organizing things.