Yet, because Moses gave you circumcision (though actually it did not come from Moses, but from the patriarchs), you circumcise a child on the Sabbath.
The command to be circumcised originally was given to Abraham, (Gen 17:10-12) but it was later included in the Law of Moses. (Lev 12:3) Even though they would have kept the command given to Abraham and his descendents, the Law carried greater weight and they obeyed the command because of what Moses had written.
Gen 17:10-12 This is my covenant with you and your descendants after you, the covenant you are to keep: Every male among you shall be circumcised. You are to undergo circumcision, and it will be the sign of the covenant between me and you. For the generations to come every male among you who is eight days old must be circumcised, including those born in your household or bought with money from a foreigner—those who are not your offspring.
Lev 12:3 On the eighth day the boy is to be circumcised.
“we do not circumcise because Abraham our father, on whom be peace, circumcised himself and his household, but because the holy blessed God commanded us by Moses, that we should be circumcised, as Abraham our father was circumcised.” (Maimon. in Misn. Cholin, c. 7. sect. 6. as quoted in Gill)
The Law also required that they do no work on the Sabbath. (Ex 20:10) Even though they would do everything they could to avoid anything that even remotely seemed like work on the Sabbath, the Jews considered the command to circumcise to have precedence over the command to keep the Sabbath because it came first, and would not hesitate to carry out a circumcision on the Sabbath.
Ex 20:10 but the seventh day is a Sabbath to the LORD your God. On it you shall not do any work, neither you, nor your son or daughter, nor your manservant or maidservant, nor your animals, nor the alien within your gates.
“say they, because it is a former command, from the time of Abraham our father, on whom be peace, before the giving of the law of the Sabbath, “they circumcise on the Sabbath day,” and when the command of the Sabbath afterwards took place, it was not possible it should disannul circumcision on the Sabbath day; and for the same reason, they also allow the sacrifice of the Passover to be done on the Sabbath day, because it is a command which went before the command of the Sabbath.” (Baal Hatturim in Lev. xii. 3. as quoted in Gill)