Every diver should carry, at least, a couple spare o-rings. Into the early '90s, there were 2 types used on US yoke valves. A thin ring and a slightly thicker one. Now-a-days, there are still 2 types. The "thin" o-ring has pretty much become the standard for all yoke-only valves. But the DIN/Yoke convertible valves use the same kind of o-ring used on DIN regulators. A very thick o-ring.
When you rent a tank, you should insist on checking the tank before you walk out of the shop. This way you know if you got a full tank, and if the o-ring is good. If you discover any problem before you leave the shop, they can fix it for you.
But o-rings can fall out or get chewed up in the process of transporting and setting up your gear. Every diver should be prepared with at least a couple replacement o-rings.
As far as "can I buy them at a hardware store?" --No. I don't believe that o-rings of the correct specifications are available anywhere except at scuba shops or safety equipment dealers that supply O2 or breathing equipment.
o-rings are cheap. Buy them from your LDS or from an on-line scuba dealer.