An attacker generates a wallet address that closely resembles one you've genuinely transacted with before — typically matching the first and last several characters, since many people only glance at those when verifying an address.
They send a small, unsolicited transaction (sometimes for a trivial or even zero amount) from that lookalike address to your wallet, which causes it to appear in your transaction history alongside your real, legitimate contacts.
Later, when you intend to send funds to your real contact, you accidentally copy the attacker's lookalike address from your history instead of the correct one, and send your funds directly to the scammer.