At 4 years on a laptop, I would strongly suspect the HDD may be in the early stages of dying. Just by some fluke, the first affected areas (that you noticed anyway) were where some of your settings were stored.
If you still have the original restore media, fish that out, and follow the instructions on the disc which has Apple Hardware Test on it. It's far from a definitive test, but it's marginally better than nothing.
It could also be that whatever it is you were doing, really were enough to trigger the ensuing events. Difficult for us to say, since you don't provide any details. Still, at least you own up to SOMETHING, as opposed to trying to claim it just magically happened when you turned your back for 5 seconds like most people.
And if you've upgraded your OS to a version that has Time Machine, and you've been making regular backups with it, that would be an easy way to restore the missing data. This also might be an excellent time to start backing up things if you haven't already.
I've had my macbook pro for 4 years and we've always enjoyed a very harmonious relationship.
Until yesterday. After doing nothing at all that could trigger the ensuing events, I went to my mail to find that none of my messages would open. I then realised that other software needed serial numbers reentering. Hoping that turning the machine off and on again would remedy the glitch, I was really alarmed to find that my macbook had reverted to factory settings in all departments and needed reconfiguring.
Although I didn't lose any files or applications I seem to have lost a large chunk of my mail archive. I re-imported as much as possible from Library/mail but unless I'd stored emails in separate subject mailboxes, my main unfiled inbox and all of my sent mails don't seem to have properly backed up for 10 months. I've tried to import the ones that are there from my back up external hard drive but mail keeps crashing when I attempt the import.
So
- does anyone know a solution to my mail archive problem?
- does anyone have an idea why my mac would have done this in the first place?
Although I don't have loads of memory left I always make sure to keep enough spare to keep the machine happy . I certainly didn't receive any 'start up disk is almost full' messages before this happened.
If this was a relationship, I'd be seriously questioning our future together.

Chowhound
Comic Vine
GameFAQs
GameSpot
Giant Bomb
TechRepublic