These are called locates. Locates indicate what infrastructure is under ground. Each colour represents a different utility. These includes gas lines, underground cable, water and sewer lines and hydro wires. A flag at this site marks that one of these utilities is underground. The spray paint is the same and used on hard surfaces such as sidewalks and asphalt.
Locates must be done before digging in accordance with the law. This applies to both residents and utility companies. If you plan on doing any digging on your private property, you can arrange locates by contacting Ontario On-Call.