||We argue that photon counts in a superconducting nanowire single-photon detector (SNSPD) are caused by the transition from a current-biased metastable superconducting state to the normal state. Such a transition is triggered by vortices crossing the thin and narrow superconducting strip from one edge to another due to the Lorentz force. Detector counts in SNSPDs may be caused by three processes: (a) a single incident photon with sufficient energy to break enough Cooper pairs to create a normal-state belt across the entire width of the strip (direct photon count), (b) thermally induced single-vortex crossing in the absence of photons (dark count), which at high-bias currents releases the energy sufficient to trigger the transition to the normal state in a belt across the whole width of the strip, and (c) a single incident photon of insufficient energy to create a normal-state belt but initiating a subsequent single-vortex crossing, which provides the rest of the energy needed to create the normal-state belt (vortex-assisted single-photon count). We derive the current dependence of the rate of vortex-assisted photon counts. The resulting photon count rate has a plateau at high currents close to the critical current and drops as a power law with high exponent at lower currents. While the magnetic field perpendicular to the film plane does not affect the formation of hot spots by photons, it causes the rate of vortex crossings (with or without photons) to increase. We show that by applying a magnetic field one may characterize the energy barrier for vortex crossings and identify the origin of dark counts and vortex-assisted photon counts.