It's very easy to reproduce.
Attack something in combat. move in with other unit (not sure it's necessary).
Try to move the first unit on a spot neighbouring the previously attacked target.
Chances are good your unit will auto attack previous target regardless of having available skills/items/spells it can use
On the next turn you'll be able to use them as normal.
The behaviour is similar to the auto defense and if there is a bug I'd look it down there.