"Let Not the Believers Take for Friends Unbelievers"
"Wali" can occasionally mean friend in Modern Standard Arabic, but it is uncontroversial to say that words change meanings over time, often as societies themselves change. In English, "awful" no longer means that one is "full of awe," and there was not a word for "election" until people had the idea for them. "Sadiq," the most common MSA word for "friend," does occur in Qur'an 26:101, where everyone seems to translate it that way, as well.
In 7th century Arabic, however, a "wali" was a member of one's "'aqila." An "'aqila" was a group of people who were responsible for each other's actions in Arabian customary law. This was usually the blood relatives on one's father's side, but could include others adopted into a sort of virtual family. If in 7th-century Arabia I killed someone, my 'aqila would be responsible, either subject to vengeance from the victim's 'aqila or paying them blood money.
The verses of the Qur'an and similar stipulations in the hadith and the Constitution of Medina have nothing to do with whom you can hang out with when you go to region's weekly market. They are about whom you take responsibility for in this way, an injunction that Muslims, or at least those Muslims who converted as individuals rather than as part of an entire tribe, form a legal community of mutual aid and protection amidst Arabia's tribal feuding.
There is another angle to this. In the Constitution of Medina, it was forbidden to seek vengeance against a Muslim on behalf of a non-Muslim. If memory serves, laws of vengeance also did not apply within an 'aqila, only between 'aqilas. As Michael Lecker has pointed out, this, again in the context of Arabian customary law, was a means of ending Arabia's tribal feuds with the spread of Islam, as it meant that any individual who had been killed in the past was a non-Muslim on behalf of whom one could not take vengeance on the rapidly increasing numbers of new converts.
This understanding of "wali" would not long survive outside the society of whose moral world it was a part. By the 8th century and the imperial caliphate, the core meaning of the word came to be something like "guarantor" or "agent." It is still used that way in Islamic law. Presumably beneath the social level of the written texts the 7th-century meaning also drifted into the "friend" it can mean in Modern Standard Arabic, though as I said, that really is neither the most common meaning or the most common word for friend. I suspect it comes up in translations because it is easier to understand in contemporary English than the alternatives. That does not, however, make it right.