tl;dr: there's no distinction in this context. Courts interpret loaf to have the same meaning as loiter.
Was there an ancient distinction?
Linguistically, it's possible. Loiter likely derives from the Middle Dutch for unsteady, loose, or tottering. (The OED's nautical reference to a loitering or shivering sail makes sense in this context.) The origin for loaf is less certain, but the OED gives it a sauntering connotation, which is different. As you allude, they tend to be modern synonyms for idleness. That's partly because the modern Dutch meaning for loiter eventually approaches that of loafing. But the word seems to have entered English usage prior to the transition from Middle to modern Dutch, meaning that it changed as well.
Of interest, the dissent in Johnson v. State, 202 So. 2d 852, 854–55 (Fla. 1967), explains that a local statute (Florida in this case) inherited two broad categories of vagrancy from earlier English law:
(1) able bodied beggars, common gamblers, drunkards, railers and brawlers, thieves, pilferers, traders in stolen property, lewd persons and keepers of gambling places, who are denounced as such regardless of their financial status, and (2) able bodied persons who are habitual idlers, loafers, "hoboes", who neglect their lawful business, if any, stroll and wander from place to place without lawful purpose or object and who are without means of support or reasonably continuous employment or regular income.
The archaic-language-enabled categorizations parallel the "loitering or strolling" distinction in other statutes, as in Headley v. Selkowitz, 171 So. 2d 368 (Fla. 1965). So it's possible that the loiter–loaf diction is just a linguistic holdover from earlier English law describing shaky people and saunterers.
What is the modern position?
In order to decide cases, courts have to spend time interpreting the language in various statutes. Modern case law on the topic stems from the Supreme Court's decision in Papachristou v. City of Jacksonville, 405 U.S. 156 (1972). There it doesn't draw a distinction between the terms. Other opinions, such as The City of Olathe v. R.E. Lauck, 156 Kan. 637, 640 (1943), affirmatively declare them synonyms: "the terms 'loiter,' 'loaf,' and 'idle' are used synonymously."