If you have a high enough Illusion skill, you can use the Calm or Fear spells or their higher-level versions to prevent your follower or horse from attacking.
Mods or Console Commands
The mod Better Horses, can set horses to flee at the sight of combat, rather than getting involved and killed. This can be set to all horses except Frost and Shadowmere, or to all horses, including the mentioned two.
The Better Horses mod can also set your horse as 'essential' (i.e. unkillable) or increase your horse's health, preventing or lessening the chances of your horse getting killed. It also has other useful, optional horse-related features.
The mod, Better Stealth AI for Followers, claims to prevent followers from rushing into combat:
This mod improves the stealth AI for followers, so they don't rush
into combat before the enemy has fully detected the player. Followers
will also unequip torches while sneaking.
The mod Better Followers or Ultimate Follower Overhaul will allow you to set your NPC follower as essential, preventing them from getting killed.
Note that Better Followers and Ultimate Follower Overhaul will work for Permanent followers only and Quest followers may not be affected. Most quest followers are already set to be 'essential' though. Just be careful with those not marked as essential (see who is not set to be 'essential' here).
You could also use the setessential
console command to set your horse or follower as unkillable.
Best Answer
Unfortunately for you, I found that most caves in Skyrim follow a pattern of a series of enemies/puzzles followed by a 'boss' to defeat at the end before exiting. That being said it is possible that the cave you are in will have an exit that is accessible without having to defeat the 'boss'. But even in that case you'll most likely have to sneak past them or make use of whatever potions you might have such as invisibility/sneak. So if your sneak is of a high enough level it might be worth trying to sneak past, but I'd say going back the way you came for now is your best bet.
I always found that making my way through caves using a combination of archery and sneaking was a good way to do a good bit of damage to a group of enemies before running in with my sword. Good use of shouts such as Fus Ro Dah are also invaluable when getting swarmed as they usually let you get a good couple of swings in while the enemy is knocked back or give you a chance to 're-group'.
Hope it helps!