In simple words, AMM has to keep the balance set in the code, for example 50/50 share of assets in the pool. It means that if 1 asset’s price dumps, then poll sells some tokens from the other share, balancing it to 50/50 proportion. So in this way the pool buys “loser” tokens. If the price of one of two tokens in the pool goes up, the pool will sell some tokens of the “winner” to keep the 50/50 balance. It gives so called impermanent loss.