I think they stayed there to make sure that there would be a Jewish shomer or guardian, and also so that they’d be someone whose job it was purely to focus on the deceased rather than on clearing debris or other jobs. I believed they mostly said psalms, as is traditional for any shomer.
Other comments on what people have said:
One only washes one’s hands (at least in the Orthodox tradition) after leaving a graveyard, not necessarily because you’re about to make a shiva visit. Many Jewish cemeteries have a sink or faucet at the gates for just this purpose. FWIW, you wash your hands any time you leave a graveyard, not just after a funeral, and not just a Jewish graveyard; I annoyed my friends traveling through England because I kept hopping into graveyards to find really old tombstones, and thus kept depleting our water supply.
The ceremony (‘unveiling’) for the setting of the headstone can be at various times, depending on the family’s custom and situation, although I think the time period is between thirty days and one year after the person’s passing.
I have never heard of the custom of making sure to leave through the same door you entered, although in Orthodox shiva houses, the front door is left open so that you can come and go without needing to be let in by the mourners, and I’ve always left that way anyway. It’s quite possible that such a custom could exist; I don’t pretend to know every tradition of every community.
Avoiding leather shoes and makeup, as well as sitting on low chairs, are for the close relatives (parents, siblings, children, and spouse) of the deceased. You can wear what you like, sit on a normal chair, etc. There is no particular tradition of wearing black to a Jewish funeral, although people tend to avoid particularly bright colors and dress a bit more formally if possible. Shiva visits aren’t formal dress occasions, and you can wear whatever it is you’d normally be wearing that day.
At Orthodox funerals, the mourners will try to fill in the entire grave if there are enough able-bodied people present to do it. I’ve been at a few poorly-attended funerals where there were only three or four people young and strong enough to shovel, and it’s sad to me that we could only do the minimum, ie cover the coffin until it was not visible.