Molecular evolution in star-forming cores: From prestellar cores to protostellar cores