Not sure how to reproduce this, but I notice that sometimes (seemingly only in spots with a lot of mobs around) that if I right click to cast a spell that the character will start moving to that spot as if I left clicked instead of casting the spell.
It happens to me as well, just hold down the right mouse button for a second longer and it should work normally despite any lag you may/may not have.
Further testing: Monster zoo room. I can see all the monsters. I am standing outside the room and using Fireball spell, i attempt to click on a mob in the room. Instead of firing the spell, he starts walking to the spot. I tested after the room was clear, standing outside the room and trying to fire inside. The fireball went off no problem on any space that was in my line of sight. If I try casting on a spot I already saw but is now darkened out because I no longer have line of sight, the spell wont even cast. I thought the issue might be me trying to cast on a space no longer in line of sight that had a mob on it, but because the mob was on it, I couldnt tell the space was darker to indicate it being out of line of sight, and I thought maybe there was juts a bug that was causing me to see the mob regardless of that space being out of line of sight, and that the game would move the character INTO line of sight automatically if you're trying to cast on a space that isnt, but that doesnt seem to be the case after testing with all mobs dead. So yeah i have no clue, seems that for some reason some spells will cause you to start walking to the space you cast it on instead of just casting the spell, and it only seems to happen with a lot of mobs in the area.