Yams are a type of tuber that people eat. They are very starchy and are a primary food source for millions of people worldwide. Being a tuber, yams grow underground and store nutrients for the yam plant for winter. This makes them quite nutritious. However, tubers do not contain seeds, and thus yams are not fruits. They are therefore vegetables.
Part of the reason someone, naïve of botanical details, might think that yams may be fruits is because of the prevalence of these cans in North American supermarkets:
These are admittedly sweet, similar to the typical fruit. However they are not fruit. In fact, they are not yams. Note that despite saying “YAMS” in big, bold letters, you can also see—in small font less than a fourth the size—it say “cut sweet potatoes” underneath. Yams and sweet potatoes come from two entirely different plants. Sweet potatoes are still vegetables, but they are tuberous roots, not actually tubers which come from the stem. It is unlikely that most Americans have actually eaten a true yam. They are essentially only grown in Africa and are much closer to regular potatoes. They are not sweet and are quite tough, even after being cooked. Indeed, yams have little to nothing in common with fruits other than just being roundish edible plant parts.