Replace material and texture with python in BGE
UPBGE has a Replace Material API, but regular BGE does not. However, you can replace the material with a custom GLSL shader.

Changing textures is not doable, but you can replace the images used in a material. A simple python function that does this is:

def show_picture(obj, path, mat_id=0, tex_id=0):
    '''Loads a picture into a texture'''
    prop_name = 'SHOW_PICTURE{}:{}'.format(mat_id, tex_id)
    if prop_name not in obj:
        tex = bge.texture.Texture(obj, mat_id, tex_id)
        obj[prop_name] = tex
    else:
        tex = obj[prop_name]
    raw = bge.texture.ImageFFmpeg(path)
    if raw.status == 0:
        # Error in loading image
        bge.log.error("Unable to load image at {}".format(path))
        raise ValueError("Unable to load image at {}".format(path))

    tex.source = raw
    tex.refresh(True)


Where tex_id is the texture slot of the image.