>>98164760 the short answer is that gimli and legolas had a rivalry, and people copied that but without the nuance of them becoming good friends or the context of it just being gimili and legolas specific and not every dwarf and every elf
the longer answer is that they are visual foils to each other and the RPG-versions of them, distinct from tolkien, have developed in opposite directions elves are graceful warriors with an emphasis on graceful weapons like swords, daggers, and bows dwarves are stocky and direct and are depicted as using axes and hammers while their cultures heavily depend on the setting, the usual interpretation is that elves prefer forests while dwarves prefer mountains
so you have two groups of people who have, intentionally or not, drifted to become near total opposites of each other in visuals and beliefs so its the next step to depict them as at leasr rivals, if not not outright enemies