If a disciple of Christ does not follow the Master’s discipline, that disciple will be rebuked. If that disciple does not repent, fellowship with that erring and impenitent disciple may need to be withdrawn.
Assuming that the "disfellowship" has been done according to the Lord’s will, what is the relationship of the disciples to the one they have withdrawn from? How should they regard and treat the disfellowshipped person?
"Let him be to you as a Gentile and tax collector."
Jesus is talking about someone who has been rebuked privately but will not listen. He has then been rebuked by the congregation but still will not listen or repent. So the disciples exclude him from fellowship.
Jesus says to treat that person as a Gentile or tax collector. When Jesus said this, the Jews kept away from Gentiles who were not God-fearing thinking of them as unclean. And tax collectors were mostly corrupt in their dealings as implied by John the Baptizer who told them to collect no more than was appointed (Luke 3:12-13).
A Christian who is sinning and refusing to repent is to be regarded as the Gentiles and tax gatherers were generally regarded. A disciple who goes back wilfully to "fellowship in unfruitful works of darkness" (Ephesians 5:6-12), is not entitled to fellowship with the disciples of Christ.
"Note those who cause divisions and occasions of stumbling contrary to the teaching you have learned. Turn away from them."
The actions recommended here are firstly to "note" and secondly "turn away". In another letter Paul writes, "Withdraw from every brother who walks disorderly... take special note of that man and do not keep company with him" (2Thessalonians 3:6,14).
This turning away and withdrawing is also described as rejecting and removing (Titus 3:10, 1Corinthians 5:7,13b).
But perhaps the strongest language Paul uses for withdrawing fellowship is "deliver such a one to Satan" 1Corinthians 5:4-5). Erring disciples who are removed from fellowship in Christ no longer have Christians for company. They have only those who follow Satan. It is hoped this will cause them to repent and return just like the prodigal son.
"Do not keep company... not even to eat with such a person."
The fellowship of the early Christians included "sharing their meals from house to house " (Acts 2:46). A "disfellowshipped" person is excluded from such get-togethers. "Do not welcome him into your house or greet him" (2John 1:9-11).
This all sounds harsh and unpleasant. Indeed it is, but the purpose is to stop the person from corrupting other disciples and to shock the person into repentance and returning to fellowship.
So Paul urges, "Do not treat him as an enemy, but admonish him as a brother" (2Thessalonians 3:15).