As Mark C. Wallace noted in his comment, this is from the Spartan poet Tyrtaeus whose verse became an integral part of the Spartan military ethos and propaganda. His exhortations to fight bravely were seen by classical authors as one of the keys to maintaining the morale of Spartan soldiers.
To answer your question, "To what extent was this observation true at the time and why?", it was very important due to the hoplite (heavy infantry) tactics of the time and the importance of maintaining an unbroken line in the phalanx (military formation). Further, a soldier who fled deprived his neighbour in the line the protection of his aspis or hoplon (shield). Hence, from Plutarch,
Asked why it was dishonorable to return without a shield and not
without a helmet, the Spartan king, Demaratos (510 - 491) is said to
have replied: "Because the latter they put on for their own
protection, but the shield for the common good of all."
A phalanx that held firm was a formidable force, but one that broke became extremely vulnerable as the soldiers relied on each other for strength and protection. Further, a fleeing soldier may lead to others doing so, further sowing the seeds of panic and, ultimately, almost certain defeat. This was also true for other formations in later periods that used shield wall tactics (e.g. the Anglo-Saxons).
In ancient Greece, individual hoplites, being heavy infantry, were vulnerable to faster, more mobile light infantry and could thus easily be chased down if the formation broke (even more so if the opposition had cavalry). Remaining in formation at least allowed the possibility of an orderly retreat.
However, there is also an element of instruction and propaganda in the sense of impressing upon Spartans that fleeing from battle was not an option as those who fled would be disgraced and would become social outcasts. Hence, Plutarch again:
"Come back with your shield - or on it" (Plutarch, Mor.241) was
supposed to be the parting cry of mothers to their sons. Mothers whose
sons died in battle openly rejoiced, mothers whose sons survived hung
their heads in shame.
Also, from Tyrtaeus himself:
Fear ye not a multitude of men, nor flinch, but let every man hold his
shield straight towards the van, making Life his enemy and the black
Spirits of Death dear as the rays of the sun.
In the lines following this, Tyrtaeus mentions past experiences where Spartans fled and the consequences (this has been interpreted by some academics as a reference to setbacks during the First Messenian War and against the Argives):
ye have tasted both of the fleeing and the pursuing, lads, and had
more than your fill of either....no man could tell in words each and
all the ills that befall a man if he once come to dishonour.
Note, though, that Spartans (despite the propaganda and subsequent mythologizing) did sometimes retreat (e.g. the tactical retreat at Plataea in 479 BC), and that not every battle where they fought against the odds was a 'death or glory' Thermopylae. The key point was not to abandon your comrades, an action which would make both you and them more vulnerable.
Tyrtaeus was not, of course, the only one to purvey this message. The Greek philosopher Onasander (1st century AD), in The General (Strategikos), wrote that a general
must show by many reasons that death is certain for those who flee,
since the enemy would at once press on freely, as soon as no one is
able to hinder the pursuit, and could dispose of the fugitives as
might suit them; but for men who stand and defend themselves, death is
As to your second question, "How does this compare to now?", this depends on circumstances but, generally speaking, abandoning your own side obviously isn't helpful. It's also bad for morale and can lead to a more general panic in the ranks.
Scott M. Rusch, 'Sparta at War: Strategy, Tactics and Campaigns, 950-362 BC' (2014)
Paul Cartledge, 'Sparta and Laconia: A Regional History, 1300-362 B.C.' (2002)
John R. E. Bliese, 'Rhetoric Goes to War: The Doctrine of Ancient and Medieval Military Manuals'. In Rhetoric Society Quarterly, Vol. 24, No. 3/4 (Summer - Autumn, 1994)