One should think of all the consequences of an action, and be prepared for some unexpected, negative results.
The origin of this saying is Aesop's Fables, the world's best known collection of morality tales (circa 260 BC).