Alkali shows alkaline properties when they're dissolved in water. Without water , the hydroxide ions in the sodium hydroxide pellet cant move freely and are tied to its lattice structure. So the pellet of sodium hydroxide doesn't show its alkaline properties thus the red litmus paper remains same. With water the hydroxide ions are produced and able to move freely in water thus the sodium hydroxide pellet can show its alkaline properties hence the red litmus paper turns blue