It is just like English sayings and phrases, there are Japanese sayings and phrases as well. It is called [kotowaza ことわざ].
犬も歩けば棒に当たる・Inu mo arukeba bo ni ataru
Even for a dog if he is stumbled about、then he might be beaten by a stick. (1). Later on the meaning has changed to that good things happen to him. (2)
(1): If you are too forward, you are likely to meet with disaster.
(2): Every dog has his day. If you just walk around, sometimes you came across unexpected happiness.
How to use it
Doyobi hima datta node, burabura sannpo shiteita. Suruto battari ojisan ni atte, ohiru o gochiso ni natta. iumo arukeba bo ni ataruda.
On Saturday I had a spare time, so I was just strolling. And then I bumped into my uncle and he treated me a lunch. Well I can say “Every dog has his day”. 。
A dog at Edo period
A long time ago, at Edo (currently Tokyo), there were so many dogs. At that time, because there was no custom to have [keep] a dog on a lead, not only stray dogs but also pet dogs were prowling around throughout of the towns.