The expression “Having your back to the wall” comes from street fighting and means you’re in a desperate situation.
And although there is no room to retreat you might still win if you fight off the attack with renewed energy.
On the other hand, “going to the wall” means that although you are in an equally desperate situation, you are there willingly, even though there is no chance of winning.
The phrase “going to the wall” comes from the condemned facing a firing squad.
Now you know the difference between the phrases “having your back to the wall” and “going to the wall”.