How can some substances (water, for example) act in some reactions as an acid and in other reactions as a base?

I don't need the name. I just want to know why because google wasn't very helpful