As we learned in the introduction to Massekhet Temura, once someone has sanctified an animal to be brought as a sacrifice, it is forbidden to try and exchange that animal with another, bringing the replacement as a sacrifice in its stead. Such an effort will not only be unsuccessful, but both animals will end up as sanctified animals.
Everyone substitutes, men as well as women; not that one is permitted to effect substitution, but that if one did so, the substitute is sacred, and he receives forty lashes.
The penalty of lashes is the ordinary punishment given to someone who transgresses one of the negative commandments in the Torah. Tosafot suggest that the Mishna emphasizes the number of lashes meted out (forty, or, more accurately, “forty minus one”) in order to point out that the transgressor is only punished once, even though the Torah expresses the prohibition in two separate clauses (“He shall not alter it, nor change it” – see 27:10). Some explain this based on a general principle taught by the Rambam that a single conceptual prohibition will not receive more than one punishment, even if it is repeated in the Torah more than once. The Ramban disagrees with this principle, ruling that in general two punishments can be applied if the prohibition is repeated in the Torah, and, indeed, some rishonim suggest that the Mishna’s use of the term “he receives forty lashes” should not be understood as limiting the punishment, but simply as teaching that a Biblical punishment will be applied here.
In his Ḥeshek Shlomo, Rav Shlomo HaKohen of Vilna asks why the Mishna needs to teach the prohibition at all, since it is a Biblical law that is clearly stated in the Torah. He suggests that we may have thought that the prohibition was limited to a case where the owner of the sacrifice meant to remove the sanctity from one animal and transfer it to another. If, however, his intention was to sanctify the second animal by means of the first one – i.e. he planned for them to both become sanctified – that would be permissible. The Mishna therefore teaches that all such cases are forbidden.