This alleged contradiction comes from assuming Abel was doing something that Scripture doesn’t say he was. The relevant passages are:
And God said, “See, I have given you every herb that yields seed which is on the face of all the earth, and every tree whose fruit yields seed; to you it shall be for food”
Then she bore again, this time his brother Abel. Now Abel was a keeper of sheep, but Cain was a tiller of the ground. And in the process of time it came to pass that Cain brought an offering of the fruit of the ground to the Lord. Abel also brought of the firstborn of his flock and of their fat. And the Lord respected Abel and his offering
Those assuming this is a contradiction are assuming that Abel, who was commanded by God to be vegetarian, was eating the meat from his sacrifice. Matthew indicates that Abel was righteous and therefore was surely not being disobedient to God’s command in Genesis 1:29 to be vegetarian.1
so that upon you may fall the guilt of all the righteous blood shed on earth, from the blood of righteous Abel to the blood of Zechariah, the son of Berechiah, whom you murdered between the temple and the altar.
So, there is no reason to assume that Abel was eating any of the meat—and thus, there is no contradiction.
As an aside, then, why was Abel tending the flocks? We need to consider that flocks can yield many other things such as wool, milk, leather, sacrifices for sin, etc.
A fattened (well-fed and tended) lamb, for example, would likely be the one that would be producing the most wool, had the most life ahead of it, and so on; hence the most valuable. So, when Abel sacrificed the fattened ones, he was offering his best, and it was a blood sacrifice. This sacrifice was acceptable to the Lord, as it mimicked what God did with Adam and Eve as blood sacrifice (Genesis 3:21) to cover their sins (Hebrews 9:22).
The passage doesn’t indicate that Abel ate of the sacrifice, so there is really no reason to assume he did. When God sacrificed animals to cover Adam and Eve's sin, there is no indication that they ate either, and since Abel mimicked what God did, then there is no reason to believe that he would have eaten from the sacrifice.
The first possibility of eating the sacrifice would have been with Noah and his family after the Flood when they sacrificed and God told them they were not restricted to vegetarian meals (Genesis 8:20–9:3), although some of those who perished in the Flood may have disobeyed and eaten meat earlier.