The Sheaf-Theoretic Structure of Non-Locality and Contextuality