Meaning
When things are not going the way we want, when we want to change the current situation, when we are in trouble, in difficulties of any kind, when we are losing and many other scenarios, it is time to exclaim that we would like to turn the tortilla around. It means changing the situation of things. For example, if we are losing money, turning the tables means starting to make money. If we are in a bad situation with our partner, in this context it means to reconcile.
It is an expression constantly used by coaches and athletes in competitions when results go wrong.
Origin
The origin probably stems from a simple analogy made while cooking a Spanish omelette or potato omelette.
It is perhaps interesting to recall the story (true or legendary, who knows) of how our famous omelette was invented and to be able, in this way, to place a possible beginning to our verbal locution.
This very short story begins in the Basque Country, where an innkeeper was to serve General Tomás Zumalacárregui on his way to besiege Bilbao in June 1835.
Canteens were very scarce after the famines of the Carlist war. With bread, onions, potatoes and a few eggs, the good woman prepared the first potato omelette and the general had the privilege of being the first human being to taste this superb dish.
Predictably, from the obligation of having to turn the omelette upside down for the perfect cooking of this famous Spanish dish, the analogy with life situations was soon born.
Analogies with other languages
The English obviously do not express this change of situation with to turn the omelette around. Their metaphor of changing things is not based on an omelette, but on tables: turn the table around.