Your rival is, at the root, the person who shares your stream.
Latin rivus means a brook or stream. From it came rivalis, which Merriam-Webster glosses as "one using the same stream as another."
Water was precious, so neighbors who drew from the same stream were effectively competing for it. Word Histories says the plural rivales meant people who drew water from the same watercourse, often neighbors. A passage in Justinian's Digest describes such users disputing how much water each could take.
Merriam-Webster says English took the word from Middle French or directly from Latin. Its first known use as a noun is 1577, in the sense of one of two or more striving for something that only one can possess. The adjective follows in 1592 and the verb, as in "to rival," in 1607.
The Latin word had already drifted before English got it. Merriam-Webster notes that it later came to mean a man competing with another for the same woman, and English took that sense too. Word Histories finds it in Plautus's comedy Stichus, where two men share one mistress and one says "rivales sumus," which means "we are rivals." It also cites a letter of Cicero from 54 BC that uses a proverb about a man who loves himself with no rival.
What the stream gave the word is a particular kind of competition. A rival is not just anyone who wants what you want. A rival is someone close enough to be in the same place, sharing one limited resource. That is why we talk about rival firms in the same market and rival teams in the same league.
The word kept the geography even after it forgot the water.