Hamming codes are designed to correct a single error. A valid codeword $p_1 p_2 m_3 p_4 m_5 m_6 m_7$ satisfies the constraints
\begin{align}
&p_1 \oplus m_3 \oplus m_5 \oplus m_7 = 0 \\
&p_2 \oplus m_3 \oplus m_6 \oplus m_7 = 0 \\
&p_4 \oplus m_5 \oplus m_6 \oplus m_7 = 0
\end{align}
(This is arranged simply by choosing $p_1 = m_3 \oplus m_5 \oplus m_7$, and similarly for $p_2,p_4$).
If a single error occurs in one of the positions $1,3,5,7$, then the first parity check will fail. Similarly, if a single error occurs in one of the positions $2,3,6,7$ then the second parity check will fail, and if a single error occurs in one of the positions $4,5,6,7$ then the third parity check will fail. Each single error is associated with a different pattern of failed parity checks, and this allows us to locate the error and correct it.
More generally, a Hamming code of length $2^n-1$ has $2^n-n-1$ message bits and $n$ parity checks, and is able to detect and correct one error. These parameters are optimal, in the sense that if a code has $m$ message bits, $n$ parity checks and is able to correct one error, then $m \leq 2^n - n - 1$. To see this, let $w_1,\ldots,w_{2^m}$ be all possible codewords. Let $B(w_i)$ consists of $w_i$ together with all words obtained by flipping a single bit. Given a word in $B(w_i)$, we can detect whether any error occurred, and if so, fix it, recovering $w_i$. This shows that the balls $B(w_i)$ are disjoint from one another. Each one contains $1 + (m + n)$ words, and so the union of all balls contains $2^m (1 + m + n)$ words. Since every word has length $m + n$, the number of possible words is $2^{m + n}$, resulting in the inequality
$$ 2^m (1 + m + n) \leq 2^{m + n}, $$
or $1 + m + n \leq 2^n$, that is, $m \leq 2^n - n - 1$.
For general $n$, the parity checks of Hamming codes are constructed as follows. Number the positions of the bits from $1$ to $2^n-1$, and think of them as words of length $n$ over $\{0,1\}$ different from $0\cdots0$. For $i = 0,\ldots,n-1$, we have a parity check stating that the XOR of all bits at indices $\ell \in \{0,1\}^n$ satisfying $\ell_i = 1$. We choose indices $2^0,2^1,\ldots,2^{n-1}$ as parity bits (the analogs of $p_1,p_2,p_4$ above), and the rest as message bits. We can calculate the parity bits from the message bits as above.
If we start with a codeword and flip the bit at position $\ell$, then the $i$th parity check will fail iff $\ell_i = 1$. This enables us to correct the error, since its position is spelled out by the parity checks.