E[I_A] = 1 times P(A) + 0 times P(not A) = P(A). That identity is the whole idea.
Combined with linearity, it converts "how many" questions into sums of probabilities. n people randomly take hats: each gets their own with probability 1/n, so the expected number of matches is n times 1/n = 1, independent of n.
The setup trap. Index over the right objects. For adjacent same-colour pairs in a shuffled deck, index over the 51 gaps, not the 52 cards.
The variance trap. Indicators are usually dependent, so variance needs covariance terms even though expectation does not.