Then God remembered Noah, and every living thing, and all the animals that were with him in the ark. And God made a wind to pass over the earth, and the waters subsided (Genesis 8:1).
Our Bible verse tells us that God remembered Noah. God promised to deliver Noah and his family through the Flood. God was looking after Noah, and God was in control of every detail of Noah’s voyage.
One possible answer to your question is that God could have miraculously stopped animals from eating each other. There is another possibility. We know that before sin, animals only ate vegetation. By the time of the Flood, a number of animals may have become vicious because of the effects of sin. But we notice today that even with animals like wolves—which are of the dog kind—there are other dogs that are not vicious. So God could have chosen the more friendly ones to represent a kind. God could also have supernaturally caused the animals to hibernate much of the time. And Noah no doubt built cages or rooms with doors to keep the animals from roaming the ark and possibly hurting other animals.
It is good to think about these things—it helps us to see there are many possible answers to your question.
But we can be sure that as God brought the different kinds of animals to Noah, He knew what was in store. He sent the animals to the ark and He would see that the animals and the people would survive the long trip together.