Without further details, I can't say for certain what your problem is. I do know that the AI (particularly with unlocked teams) will often gang-beat the human player, and this might be your problem. The first pirate raid is dangerous, but after that they're just plain annoying.
I can only guess at what your problem is. If you think you're getting too much tech, then you're probably right. Beginners do tend to try to whip through the tech tree. The tech tree isn't meant to be completed, so doin't even try to. Pick selected technologies that you need and go with those, don't tech for the sake of teching.
So, here is some generic advice:
- Ensure you purchase the necessary population infrastructure upgrades on new planets. They will have a considerable "upkeep" cost until then, crippling your economy.
- Don't build trade ports too early. They are very expensive and can take 20-30 minutes to actually pay for themselves. Especially early game, there are much better investments of time and money.
- Your best defense is always a good fleet that can move to any planet that's under attack. Static defenses on their own are little more than a delay tactic to buy time for your fleet to arrive.
- The best static defense is the repair bay. You build them in pairs so they can repair each other, and also build any starbases nearby them. It's completely silly to build a starbase then not have repair bays to support it. In addition to helping your fleet defend, you can also retreat injured units or capital ships to be healed.
- Don't build very many light frigates at the start of the game. Instead, build military labs to access higher level units like long range frigates, flak frigates, and carriers. It's foolish to build huge swarms of a single unit type, but even moreso you want to fill out your fleet with stronger unit types early on. The light frigate is fairly weak.