Avos chapter 3, mishnah 5 - and in some versions of the Mishnah it appears as mishnah 4. Before us are the words of Rabbi Chanina ben Chachinai:
"Ha'ne'or ba'lailah" - one who stays awake at night.
"V'hamehalech ba'derech yechidi" - one who walks along the road alone.
"U'mefaneh libo l'vatalah" - he empties his mind and turns it away from Torah, without thinking about anything in particular.
"Harei zeh mischayev b'nafsho" - he bears responsibility for whatever happens to him; if something bad befalls him, it is charged to his account and he is held answerable for it.
Rabbi Chanina ben Chachinai lived - though this is not entirely certain - toward the end of the period of the destruction of the Second Beis HaMikdash, under Roman rule, and perhaps somewhere between that period and the era of the Bar Kochba revolt. The placement of this mishnah alongside those preceding it makes good sense, since here too the discussion continues to revolve around the value of Torah, its study, and the benefits it confers.
The approach of the Bartenura:
The mishnah lists two activities that carry danger. If a person engages in one of them and is not occupied with Torah, but instead empties his mind and wastes his time, he has forfeited the protection that Torah provides - and therefore, if something bad happens to him, the fault is his own. He is mischayev b'nafsho and bears the responsibility.
In detail: one who stays awake at night, at the hour when harmful forces and evil influences are about; or one who travels alone in a place known to be frequented by thieves and robbers - the listim. If a person must do so, he should at the very least occupy himself with Torah in order to protect himself; and if he did not do so, the responsibility rests upon him.
The approach of Rabbeinu Yonah:
According to his approach as well, these two situations are dangerous, but they are also times especially suited and particularly favorable for Torah study:
"Ha'ne'or ba'lailah" - there are no distractions and no work at night, and therefore it is a choice time for learning.
"V'hamehalech ba'derech yechidi" - there is no one to distract him and he is not busy with his work, so he has free time before him to think in Torah.
This is especially relevant to the era of the Roman persecutions. The Romans banned Torah study, but at night no eye is watching, and here is an opportunity to learn; so too when he is traveling alone, there is no one peering over his shoulder, and this is his moment to learn. In both of these situations, one who lets the opportunity slip away and loses it has done something wrong and bears the responsibility.
The approach of the Meiri:
In the view of the Meiri, the mishnah contains not two matters but three, and all of them are things a person does that bring danger upon himself:
"HaNe'or balailah" - one who does not sleep properly at night.
"VehaMehalech baderech yechidi" - one who walks alone in a dangerous place.
"Umefaneh libo levatalah" - one who wastes his time on idle thoughts.
As for the first: this concerns a person's biological need to sleep and rest properly. When a person does not sleep enough, there is a real danger to his mental health, and a great many bad things follow from it.
True, there are extraordinary Torah scholars and roshei yeshivah who seem to be accompanied by a good angel; they learn and sleep only about four hours a night. Two of my own close teachers were like that: Rabbi Yitzchak Berkovits, who sleeps from ten until two in the morning and is awake the rest of the time; and Rabbi Chaim Zev Malinowitz, who slept perhaps even less than that and was always available and always awake. But this is not the model to imitate - these are exceptions, and one cannot derive the rule from them.
The Mishnah in the sixth chapter of Avos lists "mi'ut sheinah" (minimizing sleep) as one of the ways in which Torah is acquired. "Mi'ut" means optimizing sleep, not minimizing it - obtaining the amount of sleep one needs, and exactly that amount. Striving to sleep too little is not healthy at all, and it is even counterproductive. The famous stories on this subject are many: the Chofetz Chaim was unable to learn for an entire year because he had not slept enough, and so on. A person must sleep at night, and one who does not get the rest he needs - certainly when he is wasting his time scrolling on his phone, reading the news and other nonsense when he could be sleeping - has made a very poor decision, and the price it exacts is heavy.
Rabbi Noach Orlowek, one of my teachers, would derive a precise lesson from the wording of the verse "vayehi erev vayehi voker": first night and then day, for the day begins with the night before it. One who does not get a proper night's rest has ruined the rest of his day.
As for the second: walking alone in the time of Chazal was certainly dangerous, since there was no strong rule of law. The same applies to walking the streets at night - strolling through Manhattan at two in the morning is also a dangerous thing to do. It is not advisable, and one who does so bears responsibility for his actions.
As for the third: one who wastes his time and turns his mind to idle thoughts. There is the well known expression that idle hands are the devil's workshop - it is not a Jewish expression, but there is truth in it. When a person has nothing to do, he gets entangled in things that are not good, or at the very least he becomes bored, and a bored person is practically driven out of his mind by boredom.
It emerges that these are dangerous things, and the choice is in a person's hands: let him take responsibility, sleep well at night, avoid dangerous places, and not waste endless amounts of time, but rather do something constructive and keep himself occupied so as to stay out of trouble. And if he does not do so - "harei zeh mitchayev benafsho" - the blame rests on him and he will have to answer for it. This is the plain meaning of the Mishnah according to the Meiri.