Well, first of all, it doesn’t say you should “put away childish things.” It says (in I Corinthians 13, the well-known “love chapter”):
When I was a child, I spake as a child, I understood as a child, I thought as a child: but when I became a man, I put away childish things. (King James Version)
“I put away” is speaking in the past tense of what “I” did, not of what you must do. More likely it implies what you/they have done, because Paul was addressing adults in the church at Corinth.
Other translations echo this pretty closely. The New International Version, for instance, says: When I became a man, I put the ways of childhood behind me. The link I provided allows you to compare numerous translations, all with slightly different wording.
I’m not trained in the explication of scripture, but I can tell you how I read it, and this is with the benefit of many years of church and Sunday school under my belt before I put away those things myself.
First, look at the context. This part of the chapter is talking about how imperfect our knowledge and understanding are and what it will mean when all is revealed (presumably through Christ). I take this excerpt to be an analogy, coming as it does right after this:
For we know in part, and we prophesy in part. But when that which is perfect is come, then that which is in part shall be done away.
This part says that when the perfect comes, the imperfect falls or passes away. LIKEWISE (as I interpret it), we let the imperfections, inadequacies, or simply incompletenesses of childhood fall away from us when we become mature adults. When we grew up, we simply did put away the state of childhood and all that goes with it.
I think Paul is explaining how the coming light will just naturally take the place of the present semidarkness in the same way that adulthood replaces childishness.
I’m sure that countless sermons have been preached on this famous chapter and countless volumes written, so my little reading of it may be far off the doctrinal mark as far as many are concerned; but the main answer to your question is that it is written not as a command but as a matter of past experience.