Every material has a property known as heat conductivity that tells you how good that material is at conducting heat. When you touch an object, it will remove heat from your hand at a rate proportional to its conductivity. In other words, it’s all about the rate at which it can conduct heat.
Carpet is mostly air and air is a poor conductor of heat. Wood is solid, so it is a better conductor. Tile and metal are even better conductors than wood. When you touch the carpet, it is not able to remove heat from your feet as easily as wood, and as a result, it feels warmer. Conversely, wood or tile or metal is able to remove heat from your foot very easily, and so it feels colder. Now you know why sitting on that porcelain toilet seat in the morning feels cold and why wearing socks works so well at insulating your feet.
It’s probably worth mentioning that this coolness depends on your foot being warmer than the surface it is touching. If the floor was hotter than your feet, tile would feel hotter than carpet because it could transfer heat to your body faster. This is why a backyard that is made of stone that has had the sun beating down on it all day can feel super hot and you might quickly jump back onto the door mat or in the shade to get some relief.
Note that this doesn’t have anything to do with specific heat, which is something else entirely. Specific heat has to do with how much energy is needed to raise an object’s temperature. Heat conductivity is all about the rate at which the material can conduct heat. Simply put, tile is the better conductor of heat than wood or carpet and can take away the heat from your feet faster than the others.