Being “on the lam” means to be on the run and became popular in the American underworld near the end of the nineteenth century.
Lam is from the Viking word lamja meaning “to make lame” and was used in England during the sixteenth century as “a sound beating.”
The words lame and lambaste are related.
If someone hit the road because staying would result in severe punishment, they were “on the lam” or on the list for a beating, or worse.
Baste is from a Nordic word meaning “thrash” or “flog,” so lambaste is an even more severe beating.