Why do people spit? Very similarly to why people fart. An uncomfortable feeling wells up in your throat which needs to be addressed i.e. spat out. In preference to swallowing. Yuck.
Australian term: Hacking up a gooly and hooing it out.
Discretion needs to be exercised. Out on the street? Look for a shrub or bush. In a supermarket? Look for an item that is not very popular. Remove the first few items from the shelf and hack it up. Replace stock. By the time it is discovered, it would have evaporated. No harm done, and saves dirtying the floor.
cheeses - who would rather step in spit than dog shit. :-)