It is just like English sayings and phrases, there are Japanese sayings and phrases as well. It is called [kotowaza ことわざ].
Today’s kotowaza
犬も歩けば棒に当たる・Inu mo arukeba bo ni ataru

The Origin
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)
Its meaning
(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.

arigato