The only way to to lose the game is to lose control of all your planets.
My only guess as to what happened to you would be culture (essentially propaganda), which would enable an enemy to cause your planets to revolt without ever having to attack them. If all your planets revolted, you would lose regardless of your military standings. This is exceptionally rare, and once you become experienced you're unlikely to lose a single planet, much less your empire, to culture.
There are three ways to repulse culture. The first is to create your own culture and fight fire with fire. The second is to attack the enemy's worlds and destroy their culture generators. The third path is to station your own capital ships in friendly worlds, which mitigates the effect of enemy culture. In the long-run, you need to have culture of your own, but in the short-term attacking the enemy or stationing capital ships is a good temporary "band-aid" solution.
You can tell that there is culture in play when your enemy's colour begins to spread along phase lines. If the spread reaches one of your planet, that planet begins to fall under the influence of enemy culture and loyalty will begin to drop. If loyalty reaches zero, you lose control of the planet. As well, planets under enemy culture give the enemy fleet a combat bonus when fighting there!