Why is it okay for a married man to become a deacon, but not okay for a deacon to get married?
Not sure a canonical answer on this subject matter is going to be found, seeing that this is a question of Church discipline at the present moment in time.
For clarity sake, it should be noted that permanent deacons who are married need the consent of their wives to become ordained deacons in the Catholic Church. Permanent deacons may not remarry after the death of their spouses.
This is basically a question of Church discipline about clerical marriage.
Clerical marriage is a term used to describe the practice of allowing Christian clergy (those who have already been ordained) to marry. This practice is distinct from allowing married persons to become clergy. Clerical marriage is admitted among Protestants, including both Anglicans and Lutherans.
Many Eastern Churches (Eastern Orthodox, Oriental Orthodox, or Eastern Catholic), while allowing married men to be ordained, do not allow clerical marriage after ordination: their parish priests are often married, but must marry before being ordained to the priesthood. The Catholic Church not only forbids clerical marriage, but generally follows a practice of clerical celibacy, requiring candidates for ordination to be unmarried or widowed. However, this public policy in the Catholic Church has not always been enforced in private.
There is no dispute that at least some of the apostles were married or had been married: a mother-in-law of Peter is mentioned in the account in Matthew 8:14, Mark 1:29–34, Luke 4:38–41 of the beginning of Jesus' ministry. 1 Timothy 3:2 says: "an overseer (Greek ἐπίσκοπος) must be ... the husband of one wife". This has been interpreted in various ways, including that the overseer was not allowed to remarry even if his wife died.
Evidence for the view that continence was expected of clergy in the early Church is given by the Protestant historian Philip Schaff, who points out that all marriages contracted by clerics in Holy Orders were declared null and void in 530 by Emperor Justinian I, who also declared the children of such marriages illegitimate.
Schaff also quotes the account that "In the Fifth and Sixth Centuries the law of the celibate was observed by all the Churches of the West, thanks to the Councils and to the Popes. In the Seventh and down to the end of the Tenth Century, as a matter of fact the law of celibacy was little observed in a great part of the Western Church, but as a matter of law the Roman Pontiffs and the Councils were constant in their proclamation of its obligation." This report is confirmed by others too. "Despite six hundred years of decrees, canons, and increasingly harsh penalties, the Latin clergy still did, more or less illegally, what their Greek counterparts were encouraged to do by law—they lived with their wives and raised families. In practice, ordination was not an impediment to marriage; therefore some priests did marry even after ordination." "The tenth century is claimed to be the high point of clerical marriage in the Latin communion. Most rural priests were married and many urban clergy and bishops had wives and children." Then at the Second Lateran Council of 1139 the Roman Church declared that Holy Orders were not merely a prohibitive but a diriment canonical impediment to marriage, therefore making a marriage by priests invalid and not merely forbidden.
The Catholic Church
Like the Eastern Churches, the Catholic Church does not allow clerical marriage, although many of the Eastern Catholic Churches do allow the ordination of married men as priests.
Within the Catholic Church, the Latin Church generally follows the discipline of clerical celibacy, which means that, as a rule, only unmarried or widowed men are accepted as candidates for ordination. An exception to this practice arises in the case of married non-Catholic clergymen who become Catholic and seek to serve as priests. The Holy See may grant dispensations from the usual rule of celibacy to allow such men to be ordained. For example, some former Anglican priests and Lutheran ministers have been ordained to the priesthood after being received into the Church. The establishment of personal ordinariates for former Anglicans beginning in 2011 has added to such requests.
As in the Orthodox Churches, some Catholic priests receive dispensation from the obligation of celibacy through laicization, which may occur either at the request of the priest or as a punishment for a grave offence. Any subsequent marriage undertaken by the laicized former priest is thus considered to be the marriage of a layman, and not an instance of clerical marriage. In contrast to the Orthodox practice, however, such a married former priest may not apply to be restored to the priestly ministry while his wife is still living.
The reasoning for why deacons can not get married once ordained is because of 1.) it is Church discipline, 2.) it is a higher state of union with God through the ordination to the clerical state and 3.) the Apostle St. Paul encouragement within the sacred ministers of God to be so.
29 This therefore I say, brethren; the time is short; it remaineth, that they also who have wives, be as if they had none;
30 And they that weep, as though they wept not; and they that rejoice, as if they rejoiced not; and they that buy, as though they possessed not;
31 And they that use this world, as if they used it not: for the fashion of this world passeth away.
32 But I would have you to be without solicitude. He that is without a wife, is solicitous for the things that belong to the Lord, how he may please God.
33 But he that is with a wife, is solicitous for the things of the world, how he may please his wife: and he is divided.
34 And the unmarried woman and the virgin thinketh on the things of the Lord, that she may be holy both in body and in spirit. But she that is married thinketh on the things of the world, how she may please her husband.
35 And this I speak for your profit: not to cast a snare upon you; but for that which is decent, and which may give you power to attend upon the Lord, without impediment.
36 But if any man think that he seemeth dishonoured, with regard to his virgin, for that she is above the age, and it must so be: let him do what he will; he sinneth not, if she marry.
37 For he that hath determined being steadfast in his heart, having no necessity, but having power of his own will; and hath judged this in his heart, to keep his virgin, doth well.
38 Therefore, both he that giveth his virgin in marriage, doth well; and he that giveth her not, doth better.
39 A woman is bound by the law as long as her husband liveth; but if her husband die, she is at liberty: let her marry to whom she will; only in the Lord.
40 But more blessed shall she be, if she so remain, according to my counsel; and I think that I also have the spirit of God. -1 Corinthians 29-40
Thus we see St. Paul encouragement to remain single in order to be more free to take up our affairs with the Lord’s affairs and thus not being divided with the worries of married life and possibly the upbringing of children. Thus a deacon who got married would be divided in some respects with his service to the Church and his obligations towards his wife and the education of his children.
Again this is a question of Church discipline. The Church is trying to be prudent in this particular subject matter.
It should also be noted that the minimum age for permanent diaconate ordination is 35.
Can. 1031 §1. The presbyterate is not to be conferred except on those who have completed the twenty-fifth year of age and possess sufficient maturity; an interval of at least six months is to be observed between the diaconate and the presbyterate. Those destined to the presbyterate are to be admitted to the order of deacon only after completing the twenty-third year of age.
§2. A candidate for the permanent diaconate who is not married is not to be admitted to the diaconate until after completing at least the twenty-fifth year of age; one who is married, not until after completing at least the thirty-fifth year of age and with the consent of his wife.
§3. The conference of bishops is free to establish norms which require an older age for the presbyterate and the permanent diaconate.