The Gemara in Shabbos (132) derives from the beginning of Parshas Tazriya that if a baby is born on Shabbos his bris can take place on the following Shabbos. The Gemara (ibid 135b) derives from this pasuk as well that only if a baby was born can his bris take place on Shabbos. If a child was born through cesarean section his bris will have to be pushed off until Sunday. This is because the pasuk says that only a child whose mother gave birth (yalda) to him can have his bris on Shabbos. A cesarean section baby is considered in halacha as not being “born;” rather extrapolated from the body.
Another condition that must be met in order for a bris to occur on Shabbos is that it must be the eighth day of the baby’s life. If for whatever reason the bris did not occur on the eighth day of the baby’s life, it cannot be performed on Shabbos thereafter. This is because the reason that we may perform a bris on Shabbos, which is otherwise considered a melacha, is because the pasuk in the beginning of parshas Tazriya says “u’bayom hashemini – and on the eighth day” you shall remove his urla. The Gemara derives from the words u’bayom hashemini that a bris can override the Shabbos. However, it is only if the bris is the yom hashemini of the baby.
There is an interesting question about a bris that was not allowed to be performed on Shabbos, such as a cesarean section baby or one who is older than eight days, but was performed on Shabbos regardless. The Minchas Chinuch says that without question the bris is kosher and the mohel has transgressed Shabbos.
However, the Minchas Chinuch asks why we do not apply the halacha of “ei avid lo mehani” anything that Hashem said not to do if one does it the transaction will not work. For example the Torah says not to transfer kedusha from a korban onto another animal (temura). Therefore if one does transfer the kedusha the original animal retains its kedusha. Similarly, regarding a bris performed on Shabbos, when Hashem said not to do it, should not work.
The Mishnah in Chullin 14a says that if one shechts an animal on Shabbos the shechita is valid and the animal is kosher. There the achronim ask the same question, why don’t we apply the concept of ei avid lo mehani?
There are several answers given to that question and some may or may not apply to answer the question raised regarding a bris performed on Shabbos “illegally.” One answer given is that the concept of ei avid lo mehani only applies to transactions such as a transfer of kedusha or a sale. However on things that are not transactions rather actions that have consequences the concept of ei avid lo mehani has no bearing. This is because it does not negate that physical action that was performed. If a transaction must occur after such an action was performed the Torah can say that it will not transpire. However, the Torah does not negate physical actions.
Therefore, regarding one who shechts an animal on Shabbos since the animal was shechted, it is permitted. There is no transaction that must take place. Therefore, we do not apply the concept of ei avid lo mehani. We can presumably apply this answer to adequately resolve the question regarding a bris performed on Shabbos when it was not allowed to be.
The Minchas Chinuch quotes a different answer to the question regarding shechita. He quotes the Maharit saying that the reason that we do not apply the halacha of ei avid lo mehani is because if we would apply it then it would by default make its application not applicable. This is because if we apply it and therefore render the shechita invalid, then there was no prohibition performed. If one simply kills a kosher animal with an invalid shechita it is destructive, which is not forbidden min Hatorah, but only m’Rabanan. Since this is a cycle that does not allow for the halacha of ei avid lo mehani to be applied we do not apply it.