NoobieGirl, there's two "usual" explanations I can think of. The first explains why ships amble off on their own in gravity wells, and the second explains why they go to other gravity wells inexplicably.
1) You issue your fleet elements some orders. They accomplish those orders, and then the AI takes over for them. An example is when you tell your capital ship to go do something in an enemy gravwell, and then an enemy scout enters that gravwell. Scouts are a high priority target (and TOO high, IMO), so AS SOON AS IT FINISHES YOUR PREVIOUS DIRECT ORDER, your capship doesn't have any queued orders from you any more and goes and chases down the scout, even if it would have made more sense to go and continue bombing the planet like you had told it to do earlier. [Classic example of where this can be a pain: you tell your Vasari planet-attacker to release a siege platform, and then it does so... but then an enemy scout stumbles in and off your capship goes to take it out, instead of sensibly keeping local and sieging the planet.]
2) You didn't "deselect" the current ship before issuing a "go there" order to what you thought was a different ship or fleet element, but since you hadn't really selected the other vessel, the orders apply to the PREVIOUS ship. I do this all the time when things get busy.
Sins is pretty smart, but sometimes there's so much to do that either you end up issuing incorrect orders to the wrong ship, or it's left without orders and goes off and does some nutty stuff on its own.
-- Retro