How do I fix bad automatic weights?
My understanding of armatures (I'm far from an expert) is when you set the Viewport Display mode (in the Armature tab of the properties) to Envelope this shows each bone as a visual representation of its influence when used for Automatic Weights. In the Properties panel (N) you can set the Head Radius, Tail Radius, Envelope to control the extent of the influence of the bone and this updates the visual representation.
When you then apply the armature with Automatic Weights, it is those bone influences which are used to assign the weights to the surrounding vertices.
So, for example, you can adjust a leg bone to cover just the surrounding leg mesh and the weights are then automatically assigned as appropriate, automatically including that leg and excluding everything outside that bone's influence.