Three ways to say "I danced for three hours".
The 1st one and 2nd one are both correct, and have almost same meaning; but different emphasis.

The emphasis of the 1st one is the lasting time, i.e. 三個小時. e.g.

Q: 你跳舞跳了多长时间？ =&gt; The question is focused on how long
A: 我跳舞跳了三个小时。


The emphasis of the 2nd one is what (sb. do). e.g.

Q: 你下午做什么去了？ =&gt; The question is focused on what you did
A: 我跳了三个小时的舞。


The 3rd one is wrong. At the end of the sentence a noun is expected; which should be the object of the preceding verb, i.e. 跳.