Looking at your illustration, it seems that the mains wires are the two left wires, and the lamp would connect to the two right wires. You mentioned that the dimmer is in an enclosure. I would strongly recommend ensuring that there is absolutely no way that a determined toddler could get a screwdriver, paperclip, ham sandwich, etc... into the enclosure. Also ensure that the wires are protected with some sort of strain relief, so that when the dog trips on the cord, the wires won't come out.
I looked at your drawing again. It seems that there are two possibilities:
You are seeing 4 wires because they are 2 from the cord, and 2 from the socket. This one's easy. Connect the two wires from the plug to the left two wire positions on the dimmer. Connect the other two wires to the right two wire positions on the dimmer.
Your lamp socket is wired for a three-way lamp. Usually these have 3 wires, though. One would be the neutral, one would be low, and one would be medium. With power applied to both low and medium, you get high power. You would need to check this with an ohmmeter. With a 3-way bulb installed, measure resistances across all of the wires. You should come up with something like this:
Note that these numbers are approximate, and depend on the wattage of your bulb. This table is built on the assumption of a 40-60-100 Watt bulb. In this case, 1 and 4 are Neutral and Ground, and can be tied together. 2 is low power, and 3 is medium power. Using an external dimmer, these should also tie together for the hot side. Check across the neutral/ground and
the hot side. If it reads short, there's a problem!
If you can't figure out exactly what each wire is for, get help! Magic smoke stinks, and so do house fires. (Been there. Not cool.)
As tronixstuff mentioned before, though, mains can kill. I've been "tagged" a few times (lucky -- I'm still here to write about it) and you need to exercise the utmost caution.