Draw a square with side a+b. Split each side into a piece a and a piece b, and the square breaks into four parts: an a by a square, a b by b square, and two a by b rectangles. So (a+b)2=a2+2ab+b2. The picture works for any lengths, which is what makes it an identity, and the two rectangles are the 2ab that people forget.
Numbers can disprove a claimed identity but never prove one. Try (a+b)2=a2+b2 with a=3, b=4: the left side is 49 and the right side is 25, so it is false. Try (a−b)(a+b)=a2−b2 with a=10, b=3: 7⋅13=91 and 100−9=91. That one success is not a proof; expanding (a−b)(a+b)=a2+ab−ab−b2=a2−b2 is.
The identities you will use most are (a+b)2=a2+2ab+b2, (a−b)2=a2−2ab+b2 and a2−b2=(a−b)(a+b). They work in both directions: left to right to expand, right to left to factor. Seeing x2−10x+25 as (x−5)2 is the second identity read backwards. A sum of squares, a2+b2, has no such factoring with real numbers.
An equation like x2−49=0 looks similar but is a condition, true only for x=7 and x=−7. Substituting an arbitrary value tells them apart. At x=2, the identity x2−49=(x−7)(x+7) still holds, since both sides are −45, while the equation fails, since 4−49=0.
Think of it like this. An identity works like two spellings of one word, "colour" and "color": wherever one appears you may write the other and nothing changes. A conditional equation is more like a riddle with particular answers. Unlike spellings, an identity has to be confirmed by algebra, because a few matching examples prove nothing.
Core idea. An algebraic identity is an equation that holds for all permitted values of its variables, so it acts as an always-valid rewriting shortcut.