The Pope is not bound by Canon Law as Pope Benedict XIV states.  For centuries, the Pope has been elected from among the Major Clergy, although any Catholic man who has the use of reason can be validly elected Pope as history proves.  A married man could be elected Pope and could also retain his wife, for celibacy is a mere ecclesiastical law.  Now implicit in the reception of the order of subdeacon is the vow of celibacy, that is not to marry.  In the Eastern Rites, married men are sometime permitted to be ordained, but priests are not permitted to marry, nor is a priest who is married loses his wife may he marry another. 
Now, the question arises, can a layman who is elected Pope validly marry.  (Note, if it is valid, it would be also lawful, for the Church cannot judge the Pope.)  Normally the Pope is immediately ordained to the priesthood and consecrated Bishop. It is up to the Pope to decide whether or not he will receive the intervening Orders, which are not essential as the principle is that higher orders supply lower orders.  As history shows by the per saltam consecration as several mean to the Order of Bishop without receiving the priesthood, the Episcopate supplies for invalid priestly ordination or even if it be entirely lacking.    Now, since the Pope might not receive the sub-diaconate, has he implicitly vowed celibacy?  The answer is that he has not, and even if he had, he might be able to dispense himself.  And what of the case of a layman whose ordination is delayed by Divine Providence or even by the machinations of heretics?  He is fully Pope, but not bound to celibacy.  Therefore he can validly and lawfully marry.
However, should the Pope marry in such cases?  In taking this vow of chastity, I am closing the door on marriage, because although a Pope can do many things, he ought not to.  Recall the story of Pope Pius XII.  He invited someone over for lunch on a fast day.  He was served the usually fast day fare.  His friend commented Eugenio, why do you eat so; you are not bound to fast.  Pope Pius XII, replied: I fast because I ought to, not because I have to.  By this vow, I plan to dedicate myself fully to the service of Almighty God and His holy Church as long as He wills me to do so.  May God bless and guide me.  May the Most Blessed Virgin Mary, Patroness of the Papacy, also guide and assist me in this arduous task.  Of myself, I can do nothing, but with God all things are possible.  Please pray for me, for the Pope must be supported by the prayers of the Church!
Why is Pope Michael Vowing Chastity?