What's the consequence of losing an attack?
If your attacking Army fails to destroy the defending Army, the attacking Army is completely wiped out and you need to train new Units in the War Factory/ Garage/ Barracks in order to replenish your Army.
What's the consequence of losing while defending?
When defending against an attacking Army, any units you lose are sent to your Hospital where they can be Healed. Healing units is much faster and cheaper than training new ones.
If you are defending your Base and lose the battle, any surviving enemy units will steal some of your Resources as loot (up to the maximum capacity of their cargo space). Your Vault will protect a certain amount of your Resources from being plundered, but any Resources beyond your Vault capacity are in risk of being stolen by enemy Squads.
If your mining units got attacked and destroyed, any surviving enemy units will steal the Resources you had mined (up to the maximum capacity of their cargo space). Your units will still be sent to your Hospital.