The logic is based on the idea that right-handed combatants will find it hard to wield their weapon effectively fighting their way up a clockwise staircase as the central column will get in the way, whereas those fighting down the staircase will have plenty of room near the outer wall/bannister to wield theirs. Conversely, an anti-clockwise staircase will give an advantage to right-handed combatants fighting up, and an impediment to those fighting down.
Therefore, given that the majority of people are right-handed (and lefties are often taught to fight right-handed anyway), and the idea that if an attacker manages to enter a castle they will then be fighting their way up the stairs against defenders above, clockwise staircases give an advantage to the people tasked with defending them.
Therefore, given that the majority of people are right-handed (and lefties are often taught to fight right-handed anyway), and the idea that if an attacker manages to enter a castle they will then be fighting their way up the stairs against defenders above, clockwise staircases give an advantage to the people tasked with defending them.