Cavity-induced topological edge and corner states