Why the brain ignores what happens around us after a while?

for example a sound or a person, we knew it was there but after a while the brain ignores it and I remember that it is there and appears again