I know some of the ancient civilizations did encrypt their messages. Did it happen everywhere where writing was known? If it didn't happen somewhere, what were the reasons?
In the link to Wikipedia that you have provided it is written that the most ancient form of cryptography is the classical cypher that was invented circa 1900 BC.
Akkadian Empire knew writing and even had Enheduanna, the first poet in history whom we know by name, and established in 2334 BC and disestablished in 2154 BC. So the empire existed before cryptography was invented.
Sumer civilization is more ancient, but they knew writing as well.
About the reasons, I guess cryptography is useful only when a sufficient part of the population is able to read and write.