The transverse momentum ($p_\mathrm{T}$) distributions of $\Lambda$, $\Xi^-$, and $\Omega^-$ baryons, their antiparticles, and K$^0_\mathrm{S}$ mesons are measured in proton-proton (pp) and proton-lead (pPb) collisions at a nucleon-nucleon center-of-mass energy of 5.02 TeV over a broad rapidity range. The data, corresponding to integrated luminosities of 40.2 nb$^{-1}$ and 15.6 $\mu$b$^{-1}$ for pp and pPb collisions, respectively, were collected by the CMS experiment. The nuclear modification factor $R_\mathrm{pPb}$, defined as the ratio of the particle yield in pPb collisions and a scaled pp reference, is measured for each particle. A strong dependence on particle species is observed in the $p_\mathrm{T}$ range from 2 to 7 GeV, where $R_\mathrm{pPb}$ for K$^0_\mathrm{S}$ is consistent with unity, while an enhancement ordered by strangeness content and/or particle mass is observed for the three baryons. In pPb collisions, the strange hadron production is asymmetric about the nucleon-nucleon center-of-mass rapidity. Enhancements, which depend on the particle type, are observed in the direction of the Pb beam. The results are compared to predictions from EPOS LHC, which includes parametrized radial flow. The model is in qualitative agreement with the $R_\mathrm{pPb}$ data, but fails to describe the dependence on particle species in the yield asymmetries measured away from mid-rapidity in pPb collisions.