Such systems often include “water being strong against fire” and so on, which has a natural internal logic to it, however were there also historical/mythological precedents for these systems?
I can't speak for Eastern approaches, but the standard Western water/air/earth/fire approach is derived from Aristotlean theory of matter, which saw the four elements, the four bodily humours, the four seasons, and the properties of nature (fire rises, water falls, earth sinks, etc.) as being interlinked in one "cosmology" that explains how the world works. Here's the standard diagram to explain how they were interlinked; from this approach to "matter" Aristotle said you could understand basically everything. Some of it makes sense (add water to fire and you get air — steam), and a lot of it doesn't (like most of Aristotle's theories of nature, it makes sense if you are willing to make it make sense, but it is not predictive and has a huge amount of contradictions in it).
Aristotlean theory was predominantly used in European understanding of nature until really around the early modern period (and even then it still had its influences, well after it was determined that the world was composed of more than four elements). That a vague version of it persists in pseudo-medieval lore like D&D is not surprising, as it is not so far off the mark for what a medieval scholar might say about how the world worked (though there is much that could be said about competing systems, people who rejected this system well before the "scientific revolution," and so on). These basic ideas were also extremely present in alchemical treatises and ideas, which are the basis, as far as I can tell, for a lot of discussions of "magic" that are used in popular culture (however debased and distant from the source material — real alchemical "magic" systems would involve a lot more discussion of obscure Old Testament prophets and kings than most video games dare engage in).
Eastern cultures have similar systems but as to their specific origins, modifications, etc., I do not really know enough to say. Nor do I really know what direction the influence went (Aristotle was not inventing his system from scratch, he was clearly putting together several pre-existing systems into a coherent whole — where those existing systems came from is not something I totally understand).