Why must a physical theory be mathematically self-consistent? I always read in modern physics textbooks and articles about the need for physical theories to be mathematically self-consistent, which implies that the theories must not produce contradictions or anomalies. For example, string theorists are proud of the fact that string theory itself is self-consistent. 
But what does this really mean? Physical theories are not a collection of mathematical axioms, they are attempts at describing Nature. I understand the need for rigorous foundations in mathematics, but in physics, we have experiments to decide what is true and what isn't.
It's also weird (for me) to say that a theory is mathematically self-consistent. For example, Newton's Laws of Dynamics encode empirically known facts in a mathematical form. What does it mean to say that Newton's Laws are mathematically self-consistent? The same can be said for the Laws of Thermodynamics. There is no logical need for Nature to abhor perpetual motion machines, but from experiments, we believe this is true. Does it make sense to talk about thermodynamics as being self-consistent?
 A: Ever since the time of Newton physics is about observing nature, quantifying observations with measurements and finding a mathematical model that not only describes/maps the measurements but, most important, it is predictive.  To attain this, physics uses a rigorous self-consistent mathematical model, imposing extra postulates as axioms to relate the connection of measurements to the mathematics, thus picking a subset of the mathematical solutions to the model.
The mathematics is self-consistent by the construction of a mathematical model. Its usefulness in physics is that it can predict new phenomena to be measured. If the mathematics were patched together and inconsistent, how could the predictions of the model have any validity?
It is the demand for self-consistency that allows for falsification of a proposed mathematical model, by its predicting invalid numbers. The consistent Euclidean model of the flat earth is falsified on the globe of the earth, for example.  This lead to spherical geometry as the model of the globe. The whole research effort of validating the standard model at LHC, for example, is in the hope that it will be falsified and open a window for new theories.
A: Mathematical theories which are not consistent prove contradictory things (this is just a statement about mathematics and what it means to be inconsistent, not to do with physics in particular).
We do not want theories of physics that predict contradictory things. Ideally we don't want theories that make any wrong predictions, but if our theory makes two or more contradictory predictions about the same observation then one of them is wrong, so the theory is wrong.
Therefore, we do not want theories of physics that are mathematically inconsistent.
It's actually rather worse than this -- in an inconsistent theory using classical logic, every statement is a theorem. So it's not just that an inconsistent model makes some wrong predictions, it makes every wrong prediction you can possibly imagine, and it also makes every correct prediction you can possibly imagine. That makes it useless for doing physics, since it doesn't in any way help you distinguish between true things and false things.
There are non-standard logics that permit some contradictions without the whole thing blowing up in your face, and it may be that some physicists have made successful use of these, I don't know. If so, then there may be some special exceptions to the rule, "physical theories must be consistent", but most physicists are using standard logic and therefore cannot do anything useful with an inconsistent theory.
A: Physics is the art of compressing our knowledge of the universe.
As it happens, whenever we stick two massive bodies near each other (or notice them near each other), they seem to move towards each other.  Now, we could simply record the fact that every massive body (individually) is moving towards every other massive body (individually).  This is a large amount of information.
If we come up with a compression strategy, say a law of gravity, what we get out of it is a description of the situation that uses far less information, yet still describes what is going on.  We no longer need to describe in painstaking detail the position and attraction of every observed massive body and their tendency to accellerate towards each other: instead, we estimate their mass, and say "the law of gravitaiton applies to everything with mass".
This is a fantastic amount of compression in our description of the universe and predicting what it will do next.
Repeat this process many times, and you get modern physics, where our observations are distilled down to equations and algorithms that mean we don't have to just list all of our experiences and predictions, but rather "punt" and say "use these tricks", and the universe at least seems far simpler.
In complex situations, often the algorithms and equations don't work well (as evaluating them "fully" is hard on that scale).  But with certain assumptions we can build rules that work on different scales pretty well, like the ideal gas law and adjustments to it.
We can use this to validate our small-scale techniques by seeing if we can derive the large-scale rules from the small-scale ones.  If so, the large-scale ones are not extra rules, just consequences of the small-scale ones.
On the other hand, if it turns out that the large-scale rules are not consequences of the small-scale ones, that implies that the small-scale rules are in error in ways we don't understand yet.  This implies that the quality of their compression is less than perfect, and there may be new rules that might let us derive the actual large-scale rules from them.
If you have an inconsistent theory, that means using it will sometimes predict things that we do not experience.  This makes it a worse compression algorithm, because now you have to both talk about the algorithm and where it does not apply.  Describing where it does not apply is extra bits of information, and may require its own pattern: if you have to individually describe each instance where it does not apply, this compression is barely better than just a collection of observations and predictions with no underlying theory.
So, a consistent theory gives you the ability to describe the universe (present and future) more succinctly than an inconsistent one.
A: A physical theory uses mathematical objects to model physical systems. In broad strokes, the theory consists of (a) rules for how to relate these objects to the initial conditions of an experiment, (b) mathematical claims about properties that the model must have, and (c) a description of how mathematical characteristics of the model lead to testable predictions about the outcome of an experiment.
Of these parts (b) is what is can be thought of as the "mathematical content" of the theory. For example, with Newtonian mechanics, the model consists of functions that give the positions and orientations of various bodies as functions of a time variable, and other functions that show where the forces come from, and $F=ma$ is then a requirement that the various functions that make up the model are related in a particular way.
An theory that is not self-consistent in one where there the rules from part (b) put so many constraints on the model object that there is actually no mathematical object that satisfies all of them.
It is not unheard of that such theories can be practically useful, in that theorists manage to get predictions out of them that hold up to experiments -- but the situation is uncomfortable because mathematically it is true that the descriptions in (c) would, vacuously, lead to any prediction whatsoever about a given experiment. We only get working predictions out of the theory because the theorists limit themselves to certain particular ways of reasoning, rather than "anything that is a mathematically valid deduction from the rules in part (b)". These constraints on what kind of reasoning is "allowed" by the theory are generally neither explicitly stated or even completely understood by the users or makers of the theory.
A: 
Physical theories are not a collection of mathematical axioms, they
  are attempts at describing nature.

Not only that. Physical theories are also supposed to make predictions. This is part of the Scientific Method. One does not expect to predict new phenomena - that can later be veryfied - using a non self-consistent theory. We cannot cheat. Following self-consistent mathematics, Dirac was able to predict antiparticles, Higgs, the Higgs boson and Einstein the gravitational waves.

Does it make sense to talk about thermodynamics being self-consistent?

Just to give an example: By the beginning of the 20th century people knew the main results of thermodynamics. If you asked a student at that time what temperature is he would probably say it is the measure of the molecules' thermal agitation. But one gets this result by comparison of the pressures computed by kinetic theory and by the ideal gas law. The thing is that temperature had been used extensively until it shows up in the ideal gas law. So it is not logically consistent to use a physical variable to arrive at a result and based on this result to define this variable. To make thermodynamics self-consistent one has to define temperature by the beginning and that is what the Zeroth Law does.
A: @annav's answer already describes well how physical theories work and how they require self-consistency. I'd like to add some comments from a different perspective to that.
TL;DR Physical theories have to be self-consistent AND consistent with observation.

Mathematical self-consistency
Firstly if we treat a physical theory as a mathematical axiom system (i.e. a set of rules) it has to be self-consistent simply because otherwise it stops making sense. Here is an example of a set of rules that is not self-consistent:

  
*
  
*The sky is blue.
  
*The sky is green.

Well, that does not make sense. I know the example is silly, but this is just to illustrate the point. Self-consistency just means that there are no such rules that contradict each other.
What physics tries to do
Physics tries to find such rules that describe what we see in nature. Of course there are different philosophical stands about how many rules there should be, how many parameters we can put in (e.g. string theory tries to reduce that) and so on. But either way we want a set of rules that describes what we see. Quoting from the question:

I understand the need for rigorous foundations in mathematics, but in physics we have experiments that decide what is true and what isn't.

That is of course true. But this is an additional requirement for the set of rules. They have to be also consistent with experiment. The main point I am trying to make is: how could we possibly get the rules to be consistent with experiment when they are not even consistent with themselves?
A: To put it in a short way: Self-consistency is required because we expect nature to stick to laws that can be described mathematically. Mathematical descriptions by definition have to be self-consistent.
A: Theoretical physics is the attempt to describe a system (a subset of nature) using mathematics, making certain assumptions and idealizations if necessary. Put another way, the language of theoretical physics is mathematics. Roughly speaking, you need an axiomatization of the notion of states, observables and a dynamical law. Most physical theories have more than one equivalent description (e. g. Newton's law of motion is equivalent to the Hamiltonian formulation which in turn is equivalent to a Principle of Least Action). 
What imbues meaning into a set of mathematical equations is that you can extract predictions for experimental outcomes, and if these predictions are indeed confirmed in experiment, then you say that this set of equations describes your systems. The assumptions and idealizations also determine the range of validity: you do not expect non-relativistic quantum mechanics to accurately describe the experiments at LHC. Of course, it may happen that a single set of equations may not be able to describe all features of your system, and that is because different effects may be beyond the range of validity of a single theory. For example, the impossibility of perpetual motion machines can be derived from the Second Law of Thermodynamics, so if we were able to build one, then we would deduce that the Second Law would be incorrect. The reason physicists take the Second Law of Thermodynamics for granted is that it has been tested experimentally time and time again, and found to hold true. 
Inconsistencies in your mathematical formulation are problematic if they can be used to make contradictory predictions. Of course, not all mathematical inconsistencies need to have physical predictions associated with them, but usually mathematical inconsistencies point to errors in your theoretical description of your physical system — and to a lack of understanding of certain facets. So knowing about mathematical inconsistencies may actually be useful for physicists, because it informs them along which lines to investigate further. 
A: Good question. Is the many-world interpretation with its insistence on self-consistency and conclusions like that gravity must be quantized really preferable to the Copenhagen interpretation, which just stays agnostic on those matters? One advantage of the insistence on self-consistency is that the theory becomes more falsifiable, because it is sufficient to refute one of its conclusions to refute the theory itself. Another advantage is the possibility to interpret the theory by a "fictitious reality", as pointed out by H. Dieter Zeh.
On the other hand, we should acknowledge that the agnostic position of the Copenhagen interpretation is more honest with respect to what we really know, and also more honest with respect to the possible consequences of a refutation of the theory. None of the practical conclusions we derived from quantum mechanics will be any less valid if it would be refuted, just like none of the practical conclusions from Newton's theory became any less valid after quantum mechanics exposed its limitations. The unfounded extrapolations from Newton's theory like Laplace's demon certainly became invalid, but those should have been avoided anyway.
We can assume that general relativity and quantum mechanics both correctly describe the physical world, and use this assumption to predict things like the Hawking radiation of black holes. This prediction may be right or wrong, but it doesn't become wrong just because the combined theory of quantum mechanics and general relativity is not consistent.
A: If the only mathematical statements admitted in a physical theory were those having immediate empirical content (i.e. they can be tested by an unambiguous experiment), then you would have a very good case to make. Why? Because the consistency of the world of experience would guarantee the consistency of the mathematical formalism. End of story.
In reality, however, the mathematics underpinning a physical theory is an elaborate scaffolding which makes contact with empirical facts only at selected points. 
Here's what I mean...
You can't measure the unitary group $U_t=\exp(iHt)$ generated by the Hamiltonian of a quantum system, for example; what you actually measure is a histogram of relative frequencies of outcomes which are compared to the square of a wave function $|\psi(x)|^2$ whose form at any time is determined by some invisible mathematical scaffolding ($\psi_t(x)=U_t\psi_0(x)$ in this case).
If there is an inconsistency in the non-empirical part of a mathematical framework, it is possible (by definition) to make contradictory empirical predictions. And that, I'm sure you'll agree, is a problem. 
This is not to say that we can't cope with a mathematically inconsistent theory in physics, of course. Enter Quantum Field Theory! However the places where a mathematical inconsistency might exist need to be carefully demarcated and precise protocols mandated to ensure that two people using the same theory to solve the same problem make the same empirical predictions.
A: If theories were only used to describe what we already know and observe, maybe they would not need to be self-consistent; they could even just degenerate into big lists of observed phenomena. This is what science looked like in Sumer, 5000 years ago. If we want physical theories to be predictive, they have to be self-consistent in the sense that they have to make the same (valid) predictions whatever mathematical way you work in them. Assuming proper domain delimitation, they should also be compatible one with another, allowing mathematical reasoning to seamlessly work across a range of physical phenomena. Then we may have the feeling that we touched something deep pertaining to the nature of reality itself. Physics is based on the idea what there is more to what we observe than superficial correlations.
