There's a difference between incompetence due to lack of training from StarFleet and just getting beaten hard.That's like half the plots of Star Trek.
Given how vast the Universe is, StarFleet can afford to get beaten, even if prepared.
There's no shame in losing a battle or getting beat when the enemy is better prepared and plans a trap/ambush.
It does happen.
Look at Pearl Harbor IRL, the Japanese prepared to the N-th degree and they suffered minimal losses when they surprise attacked Pearl Harbor.
No amount of training from our side could prepare when the enemy had training, a game plan, and a surprise attack that over-whelmed our forces @ Pearl Harbor.
Granted that brought the US into WW2, but that was Japan's best shot at crippling the US' Pacific Fleet, luckily our carriers were away that fateful day on training exercises.
The difference is how we handle a situation with the training we do have, and Kirk's first instinct is to shoot at that massive of a Swarm instead of running away was a VERY bad decision.
He wasted too much time trying to fight instead of running away to fight another day.
They should've never let it close the web / finish it's construction.How about a REEEEALLY slow WEB of some kind?