If a cow gave birth to a creature that looks like a donkey but is really a cow, or if you have a donkey that gave birth to a creature that looks like a horse but is really a donkey, you don't need to redeem this peter chamor (the firstborn of a donkey) with a lamb or a goat, as you normally have to do with a firstborn donkey. The Torah tells us the words peter chamor, the firstborn of a donkey, the firstborn of a donkey, two times. So we repeat these words of peter chamor to tell us that the laws of peter chamor do not apply unless the one giving birth looks like a donkey and the one that's born looks like a donkey as well.
What's the law in terms of eating these animals? What do we use to determine their status? Is it how they look, or what they actually are—their parents? Let's say you have a creature that looks like a donkey but was actually born from a cow. Do we consider it a donkey because it looks like one, and therefore not kosher? Or do we say, no, since it's born from a cow, it is a cow and therefore it's permitted? And what about the donkey that gave birth to a creature that looks like a cow? Do you say you go by how it looks and therefore it's kosher (allowed to be eaten) because it looks like a cow? Or do you say that since it's actually born from a donkey, it becomes forbidden because biologically what it's born from is a donkey?
The Mishnah answers: A kosher animal gave birth to something that looks like a non-kosher (not allowed to be eaten) animal. It's allowed to be eaten. It's kosher. Even though it looks like a non-kosher animal, bottom line, where does it come from and what is it really? The answer is it comes from a kosher animal, so it's a kosher animal as well. On the other hand, if a non-kosher animal gave birth to an animal that looks like a kosher animal, we say it's still not kosher. It's not allowed to be eaten, because we have the following rule: Whatever comes out of something non-kosher is also non-kosher. Whatever comes out of something kosher is kosher. So an animal that's born from a cow is kosher regardless of what it looks like. An animal that's born from a donkey is also not kosher regardless of what it looks like.
But now, to apply this principle, what about if you have a fish that swallowed another fish? If you have a non-kosher fish that swallowed a small kosher fish, and you have a way to get inside the non-kosher fish's stomach, and yet you take out the kosher fish that it swallowed, that kosher fish is still permitted to be eaten. A kosher fish swallowed a smaller non-kosher fish. The non-kosher fish that was inside it, once you get it out, is prohibited for eating. Even though the smaller fish was inside the larger fish, and according to the idea we stated above—that whatever comes from something non-kosher is non-kosher, and whatever comes from something kosher is kosher—you would think that, in the example of the non-kosher fish that swallowed the kosher fish, it comes from within the non-kosher fish, so it should be asur ba'achilah (prohibited for eating). The answer is no. It doesn't apply here, because we're talking about something that grew as part of that larger fish. If it's literally part of it, and not something that it swallowed, that's when it becomes like the rest of the fish. But if it was something that it swallowed and was its own entity, its own creation, that just happened to be inside the larger fish, we go by what it actually is.

