I got a couple of good reasons why you got your ass whooped.
1) Did you search their empire or somewhere close to their empire for Weapons resource mining starbases? they easily improve the weapons of all ships in an empire and if they got it maxed then you would be having difficulty.
2) Are you engaing them in 1 impaticult area? if so then try scouting out for a millitary starbase. it will improve their ships defence and attack.
3) There is a 3rd variable apart from weapons and defences, Hit points. galactic wonders, X. hull plating, Abilities, anomilies, planet improvements + more can affect HP along with defence and weapons sometimes.
4) experience and lvl's of your ships compared to the enemy ships might be quiet low. therefor your enemies ships would have the upper hand in combat with my battle experience.
hope this helps.