There are a couple of problems.
One is that the constructor, regardless of how much damage it has taken, disappears, and "becomes" the starbase.
Two is that the starbase has shield mitigation while it is being constructed.
Three is that it takes somewhere in the vicinity of 300 DPS to take out a starbase before it finishes being constructed (on fast, anyway), assuming you start firing on it as immediately as possible.
Three is largely but not entirely the fault of two.
Four is the fact that starbase construction times in general and starbase construction times in hostile gravity wells in particular are way too fast.
As for constructing in the presence of a Vasari starbase, while targeting priority probably needs to be looked at, I'd assume that the AI didn't do one or both of the weapons upgrades.