What is the property that allows $5^{2x+1} = 5^2$ to become $2x+1 = 2$? What is the property that allows $5^{2x+1} = 5^2$ to become $2x+1 = 2$? We just covered this in class, but the teacher didn't explain why we're allowed to do it.

Everyone seems to have mentioned injectivity, but, I suppose, if you're asking a question like this then you may well not know what it means for a function to be injective.
A function $f: X \to Y$ is a mapping which assigns to each element of the set $X$ a unique element in the set $Y$.
We say that $f$ is injective if, $\forall f(a),f(b) \in Y$ we have that $f(a) = f(b) \implies a = b$. (Of course, this only makes sense if $a, b \in X$. Now you can consider this with the function $a^x, a \in \mathbb{R}$ to see how things work.

Alternatively, you could say that
$5^{2x+1} = 5^2 \implies 5^{2x - 1} = 5^0 = 1 \implies 2x - 1 = 0 \implies 2x + 1 = 2$
if you're prepared to believe that the only number which when you raise $5$ to the power of said number gives you $1$, is $0$. However, the justification for this is the above notion of injectivity, so this kind of approach is washing over the point of the deduction.
