I always ask when I see someone standing at the side of the road with their bike - especially if they are alone. Even if they are with someone I have asked - and both times it turned out one of them needed to use my air pump as their CO2 cartridge wasn't working for them and the other cyclist had neither cartridge nor pump.

Every time I've been passed by a cyclist when I have been standing at the side of the road with my bike they have asked me if I needed help, which I thought was nice. I do tend to ride in rural areas so I don't know if this makes a difference.