I know that in a CMOS sensor the megapixels give you an idea of how many pixels are actually there to capture the light. In terms of a lens however, I cannot find any relation between the megapixels of a lens and that of the CMOS sensor. I agree that sensor size is important and that all light should fall on the active area of the lens. And I get 1/3 inch lens, 1/2.5 inch and so on. But I see many lenses which say 2 mega pixel lens on them (like in this aliexpress listing). What does this actually mean?
Both Samsung and Edmund Optics use the name "Megapixel" or "MegaPixel" to describe lenses they sell for C-mount and CS-mount cameras, but in both cases the term is used like a brand name rather than a description of any technical aspect of the lens.
There's also a perceptual megapixel concept developed by DxOMark to describe lens sharpness in a way that's supposed to be more accessible than traditional MTF charts. As far as I can tell, this "P-MPix" rating hasn't really caught on yet even though it was introduced a few years ago.
The example you cited is a very small, very cheap (under $6!) lens meant for a closed-circuit TV camera. It's hard to tell exactly what the "3 mega pixel" descriptor really means, and in fact it may not mean much of anything. It may mean that the lens is sharp enough to work with 3MP sensors, or that it's sufficiently unsharp enough that you shouldn't use it with anything better than a 3MP sensor.
Sensors are manufactured to have a certain number of megapixels. Each photosite on a sensor, either CCD or CMOS, is used to generate a pixel based on the charge accumulated as a result of light falling on the corresponding light-sensitive area.
A lens is made of continuous transparent material like glass, ceramic or plastic. There are not details on it to limit where one pixel is. If one were to create a completely perfect lens, it would have a virtually infinite resolution. However, the manufacturing process gives it a limit because an imperfect lens blurs incoming light. As @scottbb notes in the comments, this would be up to the diffraction limit due to the lens aperture.
The resolution quoted for a lens by manufacturers is a measure of the degree of quality used to produce the lens. This is usually stated for industrial lenses and not for photographic ones. In its place, photo lens makers usually present an MTF chart which describes how the lens resolves details as a distance from the optical center at various apertures.
Lenses do not have "megapixels" – they are simply glass (or some other optically clear material such as certain plastics and crystals). Only the camera's sensor has "megapixels".