In the context of discussing how halakha deals with actions that will lead to a person being responsible on two different levels – e.g. he will deserve both a death penalty and to pay as a consequence of what he did – our Gemara quotes a Mishna from Massekhet Hullin (14a). It teaches that a person who performs shehita (ritual slaughter) of an animal on Shabbat or on Yom Kippur will receive the death penalty; nonetheless his shehita will be considered good, and the animal will be deemed kosher and can be eaten.
Although this ruling is presented as a straightforward halakha, the rishonim are disturbed by the fact that we ordinarily deem a Shabbat transgressor as a meshumad – an apostate – whose shehita should be considered invalid!
Tosafot in Hullin argue that not every violation of Shabbat will give a person the status of a meshumad. In fact, only someone who willfully violates the Sabbath in a public manner would be put into that category. Apparently in our case the shehita was done privately. Another suggestion raised by Tosafot is that hillul Shabbat would cause us to consider the transgressor a meshumad only after the act was done. Thus, the forbidden shehita on Shabbat would be considered valid, even as it would create a situation where any subsequent shehita done by this individual would not be accepted.
In his commentary to the Mishna in Hullin, the Rambam takes a different approach, arguing that the person in this case performing the shehita on Shabbat must have done so be-shogeg -by accident, i.e. he was unaware that it was Shabbat, or was not knowledgeable in the rules of Shabbat to know that shehita was forbidden. It is clear that someone who accidentally transgresses the rules of Shabbat is not considered an apostate. Were he to have purposefully done shehita on Shabbat, however, the meat would not be considered kosher.