First I want to mention that any kind of church action such as this is confidential. If you read about it in the media, it is because the excommunicated person has chosen to make it public. This is not something that is announced in church. Church leaders take this very seriously, and do not broadcast this type of information. In fact, if a church leader were to talk openly about these matters, it is possible that he would be removed from his position.
To understand excommunication, is to first understand what it means to be a member of the church. When we are baptized, we enter in to a covenant with God. We covenant to obey the commandments, and to be called His people. Another part of membership is that we will do nothing to fight against the church, or to teach false doctrine. If we want to be called His people, we must act as He would have us act, and show respect for His name which we bear as Christians.
When a person is guilty of serious sin, the Bishop will council with them to help them to repent. There are varying stages of action the Bishop might take. For example, he might ask them to stop doing the thing, and council them to change. Or he might ask them to not take of the sacrament for a period of time. Each action is designed to help the person think about how they can change for the better. And as I mentioned above, this is all kept in strictest of confidence. No one but the Bishop knows what the person has done, or is being asked to do.
Over time, if the person does not change, the Bishop may ask for a church court to be held. This action is not taken lightly. The purpose of the court is to determine if it might be better for the person to be removed from the covenants they made at baptism. Sin is always wrong, but to make a covenant with God, and then commit grievous sin, is very serious. So removing them from the covenant gives them a chance to overcome the sin without having the full weight of the covenant upon them. In some cases, this might take the form of "disfellowship". In the case of disfellowship, the person remains a member, but is asked to not participate actively in teaching, praying, attending the temple etc, and is asked to refrain from partaking of the sacrament. When the person has changed, and is in a position to change, then another church court is called to determine if they can be accepted in to full fellowship.
In some cases, the person is not willing to change, or over time has demonstrated that they are continuing to do what they have been counselled not to do, the church court is convened, and it may be determined that excommunication is the best course of action. This does not mean that they can never be a member again. It just means that they have been removed from under the covenant of baptism, and their name has been removed from the church membership. Elder M. Russell Ballard in his article, "A Chance to Start Over: Church Disciplinary Councils and the Restoration of Blessings" said,
"When members need to have certain blessings withheld, the Lord’s object is to teach as well as to discipline. So probation, disfellowshipment, and excommunication, when they become necessary, are ideally accompanied by eventual reinstatement and restoration of blessings. "
An overall direction to church leaders is that all of these affairs should be done with love. I remember when a friend of mine, who had church action taken against her, privately shared with me that she had never felt so much love as she did during the church council. Of course these men do not want to see anyone excommunicated. But this action can help the sinner to see the seriousness of their sin, and to make the needed changes in their life. When they are ready to live the commandments, they can make appeal to have their membership restored. In fact, it is hoped that these people will continue to attend church, even after they have been excommunicated! Everyone rejoices when someone comes back in to the fold.
God, our Heavenly Father, loves us. He is the actual Father of our spirits. Like any father, He wants what is best for us. He loves His children far more than we mortals love our own children. As our Father, He sometimes gives us discipline to help us to learn to do what is right. And when we change, and repent, He showers us with blessings. Excommunication is a chance for the sinner to start over. It is not meant to "get rid of" the sinner, but to help them to change so that they can participate in full fellowship with the church again. I hope that all who have had church action taken against them will know that they are wanted back in the church. This statement by the first presidency sums up my own feelings:
“To all such we reach out in love. We are anxious to forgive. …
“We encourage Church members to forgive those who may have wronged them. To those who have ceased activity and to those who have become critical, we say, ‘Come back. Come back and feast at the table of the Lord, and taste again the sweet and satisfying fruits of fellowship with the Saints.’” (Church News, 22 Dec. 1985, p. 3.)