>>63897755cavalry was still being used in WW1 and as mentioned above in WW2, well into the age of the machine gum
the cavalry role has not disappeared, people still need something that moves faster than two legs, and repeating rifles did not suddenly make fast movers obsolete
hell, the first users of repeating rifles in the US army were cavalry men, the spencer repeating rifle was first used by dragoons who needed to maximize firepower in a small space
what really did cavalry in was the AFV, which was even faster than the horse, could go longer distances, and was armored