For car batteries, there is terminal grease, which basically is a simple grease with corrosion inhibitors. Since it is an insulator, some pressure is required to make a good electrical connection between the contacts.
This pressure makes this grease less optimal for small connectors with lighter contacts. Here, oily contact sprays are better.
But be warned since there are often two kinds of contact sprays. For example, I know KONTAKT 60 and KONTAKT 61 from the german company Kontakt Chemie. The first is a cleaner for electrical connectors, which removes existing corrosion. This is done by some aggressive ingredients, which later will lead even more corrosion. (Like vinegar: can be used to remove rust, but also causes rust)
The second product is used after to protect the now clean contacts from further corrosion.
But in general, there often is no need for that special products. Simple petroleum jelly is often used instead of terminal grease, and a simple oil can be used instead of contact spray. They don't contain corrosion inhibitors, but due to their greasy nature, are mostly good enough.
By the way: There is a contact spray form WD40, too, but it is more a cleaner to remove grease, oil, flux and other residues from PCBs etc.