Photon and dark counts in NbN superconducting single-photon detectors and nanostripes