@Canute yes I have done all those things. Initially I thought I had better luck with the patrol setting (and thus found a justification for burning fuel "orbiting" a planet) but the problem was still happening. I also tried this with and without automation turned on. Strangely, I found very little difference in behavior. Ships were still acting based on their stances regardless of automation, and the problem was still happening.
@JDuff I agree, and I think that is the intention as it happens sometimes but not all the time. It's really only been a problem for me since shadows due to the huge number of raids I am fending off. Even with a small empire it amounts to a lot of unfun microing, and its especially frustrating when I have a sizeable defense fleet (~10 ships) in place to protect a spaceport, yet when the attack comes the defenders are a quarter of the way across the system idling in empty space, still automated, still set to defend their base, still with a range of solar system engagement only.
Anyway, one more quick question. I'm assuming the difference between defend and attack is that the defend setting will only act if something is attacked whereas the attack setting will cause ships to engage any valid target within the range. Can anyone confirm this? I've been using the attack setting because of this thinking because it should mean a quicker response in certain circumstances, but in practice they seem to work virtually identically.