It is very likely that you hit your leg and do not remember. I have a tendency to hit my legs in my sleep. I would not worry too much about that until you have more than one of them.
You could have hit it without realizing it was hard enough to leave a bruise. If you're anemic, you would bruise easily. Make sure you're getting enough iron in your diet.