### Godot version

4.01

### System information

Windows 10

### Issue description

It seems a tiles Custom Data is cleared/not set when "Local to Scene" is enabled for the TileMap in the Resource section. At least the custom data isn't set by the time of the _ready function in the script attached to the TileMap.

### Steps to reproduce

create TileMap and tileset with custom data and attached script. in _ready method attempt to read custom data from a used cell. 

In Attached project run it. It will print_debug if it found custom data or not. "Local to Scene" is enabled so it will not find the custom data.

### Minimal reproduction project

[TileMapCustomDataLocalBugReproduce.zip](https://github.com/godotengine/godot/files/11470771/TileMapCustomDataLocalBugReproduce.zip)

if (components[1] == "mode") {
				ERR_FAIL_COND_V(p_value.get_type() != Variant::INT, false);
				while (terrain_set_index >= terrain_sets.size()) {
					add_terrain_set();
				}
				set_terrain_set_mode(terrain_set_index, TerrainMode(int(p_value)));
			} else if (components.size() >= 3 && components[1].begins_with("terrain_") && components[1].trim_prefix("terrain_").is_valid_int()) {
				int terrain_index = components[1].trim_prefix("terrain_").to_int();
				ERR_FAIL_COND_V(terrain_index < 0, false);
				if (components[2] == "name") {
					ERR_FAIL_COND_V(p_value.get_type() != Variant::STRING, false);
					while (terrain_set_index >= terrain_sets.size()) {
						add_terrain_set();
					}
					while (terrain_index >= terrain_sets[terrain_set_index].terrains.size()) {
						add_terrain(terrain_set_index);
					}
					set_terrain_name(terrain_set_index, terrain_index, p_value);
					return true;
				} else if (components[2] == "color") {
					ERR_FAIL_COND_V(p_value.get_type() != Variant::COLOR, false);
					while (terrain_set_index >= terrain_sets.size()) {
						add_terrain_set();
					}
					while (terrain_index >= terrain_sets[terrain_set_index].terrains.size()) {
						add_terrain(terrain_set_index);
					}
					set_terrain_color(terrain_set_index, terrain_index, p_value);
					return true;
				}