The book of Galatians was written to saved people. They happened to live in Galatia, but they were already saved people nonetheless. (See section 17).
GALATIANS 1:1 Paul, an apostle, (not of men, neither by man, but by Jesus Christ, and God the Father, who raised him from the dead;)
GALATIANS 1:2 And all the brethren which are with me, unto the churches of Galatia:
Since the epistle to the Galatians was written to saved people, it is not about how to become saved. Instead, this epistle is more of a letter of doctrinal instruction to the church (how to live in Jesus Christ). Be that as it may, the fact that the Galatians were baptized is mentioned in this epistle nonetheless.
In point of fact, most people today have an incorrect idea of what "works" means. In this section, the biblical meaning of "works" will be examined. Briefly, to say that you're "saved by grace, not by works" means that you're not saved by works of the Law of Moses. The Law of Moses exists for the purposes of teaching us what sin is:
ROMANS 3:20 Therefore by the deeds of the law there shall no flesh be justified in his sight: for by the law is the knowledge of sin.
Furthermore, the Law of Moses provides us with the definition of what is sin and what is not. The Apostle John wrote:
1 JOHN 3:4 Whosoever committeth sin transgresseth also the law: for sin is the transgression of the law.
Therefore it can generally be said that one action is a sin, while another action is not a sin, by comparing those actions against what is written in the Law of Moses. (If anyone has a problem with that, and if he thinks he can win, then let him argue with the apostles John and Peter if he wishes, since they are the ones who wrote the above statements!) The Law of Moses was included into the world, precisely for the purpose of teaching all men that they are sinners:
ROMANS 5:19 For as by one man's disobedience many were made sinners, so by the obedience of one shall many be made righteous.
ROMANS 5:20 Moreover the law entered, that the offence might abound. But where sin abounded, grace did much more abound:
and,
ROMANS 7:7 ¶ What shall we say then? Is the law sin? God forbid. Nay, I had not known sin, but by the law: for I had not known lust, except the law had said, Thou shalt not covet.
and,
ROMANS 7:12 Wherefore the law is holy, and the commandment holy, and just, and good.
ROMANS 7:13 Was then that which is good [i.e., the Law of Moses] made death unto me? God forbid. But sin, that it might appear sin, working death in me by that which is good; that sin by the commandment [...of the Law of Moses] might become exceeding sinful.
ROMANS 7:14 For we know that the law is spiritual: but I am carnal, sold under sin.
and,
ROMANS 4:15 Because the law worketh wrath: for where no law is, there is no transgression.
ROMANS 4:16 Therefore it is of faith, that it might be by grace...
Even before Christ, those that were saved were saved by the mercy of God (that is, they were "saved by grace." Consider King David and the Bathsheba incident of 2Samuel 11 and 12). Even in the Law of Moses, it was because of unbelief that the children of Israel had to wander in the desert until that entire original generation died. (See Numbers 13 and 14, Numbers 14:11 in particular.)
The book of Galatians was written to a confused congregation of the Church. A false teacher had taught them that they had to keep the Law of Moses in order to be saved. That is, somebody had taught them that their justification (the reason why they're saved) lies in keeping the Law. Paul mentioned this topic in a conversation with Peter:
GALATIANS 2:15 We who are Jews by nature, and not sinners of the Gentiles,
GALATIANS 2:16 Knowing that a man is not justified by the works of the law, but by the faith of Jesus Christ, even we have believed in Jesus Christ, that we might be justified by the faith of Christ, and not by the works of the law: for by the works of the law shall no flesh be justified.
As stated previously, the Law of Moses was written to teach all men that they are sinners. The following scripture supports this statement:
GALATIANS 3:19 Wherefore then serveth the law? It was added because of transgressions, till the seed should come to whom the promise was made; and it was ordained by angels in the hand of a mediator.
GALATIANS 3:20 Now a mediator is not a mediator of one, but God is one.
GALATIANS 3:21 Is the law then against the promises of God? God forbid: for if there had been a law given which could have given life, verily righteousness should have been by the law.
Note: The promises mentioned here are the ones that God made to Abraham (cf. Galations 3:6-9,16).
GALATIANS 3:22 But the scripture [i.e., the Law] hath concluded all under sin, that the promise by faith of Jesus Christ might be given to them that believe.
GALATIANS 3:23 ¶ But before faith came, we were kept under the law, shut up unto the faith which should afterwards be revealed.
GALATIANS 3:24 Wherefore the law was our schoolmaster to bring us unto Christ, that we might be justified by faith.
We have just seen in section 20.1 that the Law of Moses teaches us that man sins. After all, if we transgress in one point of the Law of Moses, we would be judged simply as transgressors of the Law (James 2:10-11). Period. In this way, the law was our schoolmaster, per Galatians 3:24, because "the scripture hath concluded all under sin" (Galatians 3:22).
Since we have been determined to be under sin, the Law of Moses has invalidated any claim that we may have about either the good deeds that we may have done, or about the general virtue of our own lives. Therefore, we have nowhere else to turn, but to the grace (mercy) of Jesus Christ. In this way, the Law was our schoolmaster to bring us unto Christ, per Galatians 3:24. Since our works, or virtue, has been undone by the Law of Moses, the only way we have in which to approach Christ is by faith in Him.
GALATIANS 3:25 But after that faith is come, we are no longer under a schoolmaster.
GALATIANS 3:26 For ye are all the children of God by faith in Christ Jesus.
Note: It must be remembered, however, that the Galatians to whom Paul was writing were already saved. This statement (and this epistle) is about how to remain saved, or, how to live. It is not about how to become saved.
GALATIANS 3:27 For as many of you as have been baptized into Christ have put on Christ.
GALATIANS 3:28 There is neither Jew nor Greek, there is neither bond nor free, there is neither male nor female: for ye are all one in Christ Jesus.
GALATIANS 3:29 And if ye be Christ's, then are ye Abraham's seed, and heirs according to the promise.
Just as it was in section 16.1.3, it was understood in those days that the disciples of Christ had each been baptized in water. Galatians 3:27 provides more evidence of this, for Paul did not say "for ye have put on Christ." He said "for as many of you as have been baptized into Christ have put on Christ." Paul, writing to the church at Galatia, was writing to a bunch of baptized people.