I completely blackened my big toenail last May, it didn't fall off until last week (well, the little bit at the end that hadn't grown out). Still looks really weird though. After it happened, it was tender for a few days, but I just left it alone and had no problems, but beware, as it keeps growing out, it will still probably keep coming out black as you probably damaged the nail bed.
As for what caused it, no idea. Mine was from using slightly too loose shoes playing indoor soccer, and stopping to quickly and jamming it into the end of the shoe. Never doing that one again.
Good luck with it though.