Other people have mentioned the possibility that $P$ and $\neg P$ could both be consistent with the axioms, in which case $P$ is independent of the axioms, and you can't derive a contradiction from either assumption.
I might also add that in intuitionistic logic, it isn't just true that proof by contradiction might fail, it's that it cannot possibly succeed. The problem described above is actually a fundamental limitation in mathematical logic. Gödel's incompleteness theorem tells us that every set of axioms powerful enough to define arithmetic on natural numbers will have this problem, so every definable system of logic will have an infinite number of statements that are neither true nor false within that system. Because of this, there is a problem in the very premise of proof by contradiction, which is the claim that, "if it's not false, then it must be true!"
Intuitionistic logic addressed this problem by stepping back from the assumption of classical logic that every statement is either true or false, because that appears to be demonstrably wrong! Instead we say that a statement $P$ is true if and only if it is a logical consequence of our axioms and inference rules. The only way to prove a statement is true is to constructively provide evidence for it, because that's what truth means! Falsehood also has a different meaning than in classical logic. Saying a statement is false, $\neg P$, is equivalent to saying $P \rightarrow \bot$, where $\bot$ (pronounced "bottom") can be thought of as evidence that every statement is true. So $\neg P$ is another way of saying that evidence for $P$ would cause the principle of explosion to kick in.
Proof by contradiction works by asserting $P \lor \neg P$, which I would translate to, "either I can provide evidence for $P$, or I can prove that $P$ implies everything is true." When phrased this way, the law of the excluded middle suddenly seems way less intuitive. Furthermore, you may notice that in this view of logic $\neg (\neg P)$ is not equivalent to $P$, but a statement that $(P \rightarrow \bot) \rightarrow \bot$! This is important, because now I can prove that $P \rightarrow \neg (\neg P)$, but I cannot prove that $\neg (\neg P) \rightarrow P$, which is the final step in every proof by contradiction. $((P \rightarrow \bot) \rightarrow \bot) \rightarrow P$ simply does not follow, so we consider it to be invalid and say we need more constructive evidence to support $P$.
In short, intuitionists are real. We walk among you. And we are here to tell you that proof by contradiction will always fail. Cheers!