In English, as in other languages, words can have one or more senses (i.e., meanings).
Replace has three common senses:
1 : to restore to a former place or position
replace cards in a file
2 : to take the place of especially as a substitute or successor
3 : to put something new in the place of
replace a worn carpet
As Specmaster said, the correct sense must be deduced from the context in which the word is used.