Butter turns grainy in hot climates because the different types of fats within it melt at varying temperatures, causing them to separate and recrystallize unevenly, resulting in a grainy texture.
Butter is an emulsion of water in fat, composed of various triglycerides (fats) with different melting points. When butter is exposed to high temperatures, the liquid oils separate from the solid fats. If the butter then cools slowly, these fats can recrystallize into larger, more distinct crystals. This uneven recrystallization is what gives butter a grainy or sandy texture. The higher the temperature and the slower the cooling process, the more pronounced this effect will be. The grainy texture is not harmful, but it can affect the butter's spreadability and overall mouthfeel. The process is similar to how chocolate can 'bloom' when exposed to heat, resulting in a white, chalky appearance.
To minimize graininess, store butter in the refrigerator and only take out what you need. If butter has already become grainy, try melting it completely and then rapidly cooling it in the refrigerator. This can sometimes help the fats recrystallize more evenly, though it may not fully restore the original texture.