put them into folders sorted by version. in your mods folder have a mods\1.12.2\ and save all ur 1.12 mods there. Fabric has a rudimentary version of this feature, but wont load forge mods in folders anyways if you have it set up this way. Put all 1.19 fabric mods in the root mods folder. this isnt needed for 1.20 (therefore it wont be made). You can use viaversion (or ViaFabric+, or any sort of version compatability) with your mods Pretty sure the source is public too, you can create a fork of it and update it yourself if you wish
I am probably wrong, but I believe more recent versions removed that? If they did, you could always make multiple profiles or use prism or similar.