Understanding Transformer from the Perspective of Associative Memory