There are a lot of times where I've seen people get confused why they're unable to find specific mods and it's because they're not using the right version of Minecraft.
I think displaying the mod regardless with a visual warning saying you cannot install the mod due to Minecraft being in the wrong version will help prevent confusion, as well as help educate people on ensuring they are mindful of the version of Minecraft they pick for their personal modpacks.
I can imagine this will be hard to implement properly as you don't want to clutter the search with irrelevant mods. So, a nice solution to this could be only displaying those incompatible mods when the search yields no results. (Or maybe a little icon saying: "We found X amount of mods that fit this search but aren't compatible with this version of Minecraft, click here to view them")