This would only be possible for minor updates, such as 1.12 to 1.12.2, or very simple mods, since while you could just change the obfuscated class and method names there are often many structural changes that make it impossible to port mods to a newer version; for example, 1.8 changed how blocks and metadata and block/item rendering are handled and 1.14 completely rewrote world generation and well as made more changes to blocks/items (to the point where if you load a 1.13+ world into 1.12 or earlier the entire world will be wiped, which is also true of many other recent versions. Mojang does code in converters into the game, or rather, as a external "datafixer" library, but that is only for reading older save formats, not the code changes needed to read newer formats and the associated block/item/entity/NBT/etc handling code).
In any case, for the case of minor changes simply recompiling the code is often enough (I started making my own mods in 1.6.2 and only had to recompile them for 1.6.4; all the classes and methods still had the same names and functions. Otherwise, MCP is often to blame as they often change names for no clear reason; for example, 1.6.4's "WorldRenderer" class is entirely different from the 1.8 class of the same name, which is more like what used to be "Tessellator" in 1.6.4. That said, MCP has been dead since 1.12 and Mojang has started releasing the official obfuscation mappings so modders can now use the real Mojang class names, which remain unchanged from version to version (I'd hope that they don't decide to rename classes often).
That said, somebody actually did make a mod that could load 1.2.5 mods in 1.7.10, without even having to recompile or modify them (note that 1.7.10 was before Mojang started making large-scale structural changes to the game; the biggest change since 1.2.5 had been the merging of the client and server in 1.3.1 and even then it still worked pretty much the same as multiplayer did before. Also, many of the mods tested had various bugs and issues and it appears that they never completed it):