The Three Hundred project: the stellar and gas profiles