In Chinese, if you want to say "I ate one apple", you should say 我吃了个苹果, that is very native. Of course,"我吃了一个苹果" is OK, but not so native.
Because "one" can be omitted, if it is only one, such as,
我洗了件衣服, only one piece of clothing;
吃个梨,one pear
跳个舞, one dance
but by saying sleep, there are many ways.
first, 我睡了一觉 , that means I slept a short time, maybe ten or twenty minutes, or half an hour.
second, 我睡了个觉,when you say this, you are just trying to state the reality that you slept, the time is not what you are laying stress on, it can be long or short.
besides, if you want to say "I slept well", you say 我睡了个美觉 or 我睡了个好觉,they are all OK.
no worry, just remember it, it is about traditions in Chinese, just like in English.